const int buttonPin = 2;
const int ledPin = 11;
int currState = HIGH;
int prevState = HIGH;
int lightState = LOW;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
currState = digitalRead(buttonPin);
if(currState != prevState) {
if(currState == LOW and lightState == LOW) {
lightState = HIGH;
digitalWrite(ledPin, lightState);
}
else if (currState == LOW and lightState == HIGH) {
lightState = LOW;
digitalWrite(ledPin, lightState);
}
}
prevState = currState;
delay(100);
}