Steps for programming the board:
First I provided power to the microcontroller by connecting it to my FabISP programmer. Then I was supposed to connect the programmer to the ISP header of my “Hello button with LED” (which was powered by the FTDI cable).
The little problem was that we did not have an ISP cable available to connect both boards. We are currently working to find a new one and redo the same process to be documented here later this week. So we did the programming using the ATAVRISP2.
Burn the bootloader: We run the “burn bootloader” command to configure the fuse bits of the microcontroller so it runs at 8 MHz.
I placed a code that was provided at the as220.org website. And changed the pin numbers to the corresponded pins used for the LED and button.
programming:
/*
LED Off Until Button Pressed
Blinks a light emitting diode(LED) connected to digital
pin 7, when pressing a pushbutton attached to pin 3.
The circuit:
* LED attached from pin 7 to ground
* pushbutton attached to pin 3 from +5V
* 10K resistor attached to pin 3 to +5V
* 10K resistor pulls pin 3 and the button to HIGH by default
created 2005
by DojoDave
modified 30 Aug 2011
by Tom Igoe
modified for Hello Button + LED Board - 19 Mar 2012
by Anna Kaziunas France
*/
// constants won't change.
// They're used here to set pin numbers:
const int buttonPin = 3; // the number of the pushbutton pin
const int ledPin = 7; // the number of the LED pin
// initialize variables:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pin the pushbutton is connected to:
buttonState = digitalRead(buttonPin);
// is the push button pressed?
// if not pressed - the button state is HIGH
// the pull up resistor the button / pin 3 makes the button state HIGH by default.
if (buttonState == HIGH) {
// turn LED off (LED is off by default)
digitalWrite(ledPin, LOW);
}
//otherwise.....
// button is pressed
else {
// turn LED on:
digitalWrite(ledPin, HIGH);
}
}
Verify and Upload:
After placing the code and changing its port reference I verified the code:
After verifying I uploaded it to the board:
The uploading was successful but the LED did not shine when I pressed the button.
I suppose that the problem was with the circuit and I´ll built a new board to try the steps one more time.
|