Beginning Arduino

Been wanting to learn Arduino for a long time.  I’ve been hampered by time and lack of programming knowledge.  I’ve made the leap after fooling around with simple analog circuits and 555 timers.  I have several projects in mind.

I started learning with Lynda.com.  This was pretty frustrating since I was stuck at software debouncing and after following the instructions on the video to the letter, the program didn’t work.

const int LED = 9;
const int BUTTON = 2;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;
//
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON, INPUT);
Serial.begin(9600);}
boolean debounce(boolean last) {
boolean current = digitalRead(BUTTON);
if (last == current) {
delay(5);
current = digitalRead(BUTTON);}
return current;}
//
void loop() {
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH) {
ledOn = !ledOn;
lastButton = currentButton;
digitalWrite(LED, ledOn);
Serial.println(ledOn);}
Advertisements