2 Buttons & 1 LED, Turns ON/OFF

Description: Two buttons are used to turn an LED On and Off with an Arduino Nano.

Supplies:

1 - Arduino Nano
2 - Push-Buttons
1 - LED
1 - 220 Ohm Resistor

Arduino Code:

int ledPin = 3;
int buttonApin = 7;
int buttonBpin = 9;

void setup() {

 pinMode(ledPin,OUTPUT);
 pinMode(buttonApin,INPUT_PULLUP);
 pinMode(buttonBpin,INPUT_PULLUP);

}

void loop() {

if(digitalRead(buttonApin) == LOW) {
   digitalWrite(ledPin, HIGH);
  
}

if(digitalRead(buttonBpin) == LOW) {
   digitalWrite(ledPin, LOW);
  
}

}

Leave a Comment

35 + = 44