const int led_pin = 9; const int button_pin = 5; int led_state = LOW; void setup() { // put your setup code here, to run once: pinMode(led_pin, OUTPUT); pinMode(button_pin, INPUT); } void loop() { // put your main code here, to run repeatedly: if(digitalRead(button_pin) == LOW and led_state == LOW){ led_state = HIGH; digitalWrite(led_pin, HIGH); } if(digitalRead(button_pin) == LOW and led_state == HIGH){ led_state = LOW; digitalWrite(led_pin, LOW); } }