Can someone help me understand this code of arduino???
int switchPin = 8; int ledPin = 13; boolean lastButton = LOW; boolean currentButton = LOW; boolean ledOn = false; void setup() { pinMode(switchPin, INPUT); pinMode(ledPin, 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 && currentButton == HIGH) { ledOn = !ledOn; } lastButton = currentButton; digitalWrite(ledPin, ledOn); } As in this program when the loop runs first time and we pressed the button, current button is set as high and it satisfy the if condition , so ledOn is set to high and then last button will also set to high and led will be on , but in the second loop if I press the button again then how it will able to enter the if block because current button is high and lastbutton is also high so how the led will be off????? please help me out