1 Push-Button and 1 LED, acts like a switch

Description: One push-button is used like a switch to turn one LED On and Off with an Arduino Nano.

One Button and One LED acts like a Switch

Supplies:

1 - Breadboard 830 Points
1 – Arduino Nano
1 – Push-Button
1 – LED
1 – 220 Ohm Resistor

Arduino Code:

int button = 7;
int led = 3;
int status = false;

void setup() {
  
 pinMode(led, OUTPUT);
 pinMode(button, INPUT_PULLUP);

}

void loop() {

if (digitalRead(button) == true) {
 status = !status;
 digitalWrite(led, status);

} 

while(digitalRead(button) == true);
  delay(50);

}

Leave a Comment

83 + = 91