LED With Pushbutton
This circuit will have the LED turn on when the pushbutton is pressed.
Supplies
- Elegoo Uno R3 microcontroller board
- Breadboard
- Laptop
- Pushbutton
- 10k ohm resistor
- 330 ohm resistor
- LED
- USB cable
Attach the Pushbutton
Connect the 10k resistor and pushbutton as shown. One wire goes from 5V to the left side of the resistor. Another goes from the right side of the resistor to the left side of the pushbutton.
Finish Wiring the Pushbutton
Add one wire going from the right side of the resistor to pin 12. And add one wire going from the right side of the push button to ground.
Connect the LED
One wire goes from pin 8 to the left side of the 330 ohm resistor. The right side is connected to the long end of the LED. The short end of the LED is connected to another wire which goes to ground.
Write the Program
You must have Arduino IDE installed: https://www.arduino.cc/en/software
Here is the code: https://github.com/tejbho/ArduinoProjects/blob/main/pushbutton/pushbutton.ino
You should modify the code so the LED pin is 8 and the button pin is 12.
Downloads
Test the Circuit
Try pressing the button to see if the LED turns on.