Controlling the LED with a Pushbutton
Let's start with a simple example of the LED controlled by a pushbutton. For this project we would need:
- Arduino UNO R3 board,
- solderless breadboard,
- 10 KOhm resistor,
- momentary tactile pushbutton switch,
- a bunch of jumper wires.
Connecting the LED and the pushbutton to pins 13 and 7, we set up the Arduino input and output. Every time we push the button, we need to check the state of the input pin and store its value. If this value is HIGH, the LED turns on.
A simple circuit below gives you the idea of how to connect all your parts.
Then, upload the code into your Arduino IDE. If everything is correct, the LED will light up when you press the button. See how I did it below.Go Back