const int switchPin = 2;// the port of the pushbutton pin
const int ledPin = 13;// the port of the LED pin
boolean lastButton = LOW;
boolean ledOn = false;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop() {
if (digitalRead(switchPin) == HIGH && lastButton == LOW){
// delay(300);
ledOn = !ledOn;
lastButton = HIGH;
} else {
lastButton = digitalRead(switchPin);
// delay(300);
}
digitalWrite(ledPin, ledOn);
}