Introduction: Double Button LED

This beginner-level project is designed to help walk you through the process of having two buttons that control two separate LED lights. The LEDs act as inputs on the breadboard, whereas the buttons act as an output. With the help of Arduino Web Editor, you can easily turn on and off the LEDs.

This project was designed to help beginner coders by building on some of the more basic steps when it comes to coding. When developing this project, I noticed that it was difficult to find help with a project similar to this. All of the other ones were much more complicated than what I am capable of!

Sources:

Pushbutton (Digital Input). Tinkercad. (2021). https://www.tinkercad.com/things/8x3pCeFvMcf-pushbutton-digital-input/editel?lessonid=EJ04BAKJFSIZYJU&projectid=OMOZACHJ9IR8LRE&collectionid=OMOZACHJ9IR8LRE#/lesson-viewer.

Supplies

Arduino Uno

Breadboard

Buttons (2)

LED (2)

resistors (4)

Jumper Wires (10)

Step 1: Gather Materials

Identify the pushbuttons, LEDs, resistors, wires, Arduino, and breadboard.

Step 2: Power Supply

Connect breadboard power (+) and ground (-) rails to Arduino 5V and ground (GND).

Step 3: Extend the Rails

Extend the power and the ground rails on the respective buses on the opposite sides of the breadboard, by creating one wire between the power buses and one wire between the ground buses.

Step 4: Add the LEDs, and Resistors

Plug one LED into two different breadboard rows so the cathode (shorter, negative leg) connects to one leg of a 220-ohm resistor. Connect the other resistor leg to the ground.

Repeat with the other LED.

Step 5: Wire the LEDs

Wire the first LED anode (positive, longer leg) to Arduino pin 8.

Wire the second LED anode (positive, longer leg) to Arduino pin 12.

Step 6: Add the Pushbuttons

Add one pushbutton to the center of the breadboard and place it across the center column break, so that the legs are plugged into four different breadboard rows (two on each side of the break).

Repeat with the second push button. Make sure that the first push-button is in between the two LEDs.

Step 7: Power the Pushbuttons

Using one wire, connect the first button to power, on the opposite side of the breadboard, not the same side as the resistors.

Repeat with another wire and button number 2.

Step 8: Connecting the Buttons

Connect the diagonally opposite leg of the first button to Arduino pin 2. This is the input.

Connect the diagonally opposite leg of the second button to Arduino pin 4. This is the input.

Step 9: Resistors

Add a high-value resistor to the same diagonally opposite button leg and connect it to ground.

Repeat with another resistor and the second button leg.

Step 10: Code It

Wire the Arduino to match the pictures. Then follow the link to the Arduino Web editor for the code.

First, the BUTTONstate needs to be declared at 0 for both of the events. Next pinMode is used to clarify and declare with pins that are being used, and what they are used for. In this case, pins 2 and 4 are used as an input or the buttons, and pins 8 and 12 are being used as an output or the LEDs.

Next is the void loop () here is where were declare what is going to happen. DigitalRead is used to see what is going on with the pins, then digitalWrite is used to change what is happening. The variables HIGH and LOW are used to either turn on (HIGH) the LED or to turn off (LOW) the LED.