Code Problems Please Help

Hi I have a problem getting my codo to work. I did notice that the False statement was not coming up as declared. not sure if this is a problem with the new update or if i have done something wrong please help.


int switchPin = 8; int ledPin1 = 13; boolean lastButton = LOW; boolean currentButton = LOW; boolean ledOn = false;

void setup() { pinMode(switchPin, INPUT); pinMode(ledPin1, OUTPUT); }

boolean debounce(boolean last) { boolean current = digitalRead(switchPin); if (last != current) { delay(5); current = digitalRead(switchPin); } return current; } void loop() { currentButton = debounce(lastButton); if (lastButton == LOW && lastButton == HIGH) { ledOn = !ledOn; } lastButton = currentButton; digitalWrite(ledPin1, ledOn); }

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hiting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

How to use this forum

  if (lastButton == LOW && lastButton == HIGH)

When will this ever be true?

Have you actually got a problem that requires code to debounce a button ?

There is a very simple debounce system in several things at a time.