void loop() {
a = digitalRead(2);
digitalWrite(3, LOW);
if (a == LOW) {
while (digitalRead(2) == LOW) { //waiting for the button to be unpressed
digitalWrite(3, HIGH);
}
}
}
try this This code should light the LED and the wait for the button to be unpressed to switch off the LED. And in the future use code tag (the </> sign) while you want to post your code. And Thanks!
PS It would be much simpler if you will use something like this: