const int buttonPin = 4;
const int ledPin = 15;
int buttonState = 0;
int lastButtonState = 0;
int ledState = LOW;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH && lastButtonState == LOW){
if(ledState == LOW){
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
lastButtonState = buttonState;
}