int ledPin = 13;
int buttonPin = 5;
boolean current;
boolean previous = false;
boolean state = false;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
current = digitalRead(buttonPin);
if (!current && previous) {
state = !state;
}
digitalWrite(ledPin, state);
previous = current;
delay(50);
}