2 Alternating Blinking LEDs With an Arduino

by Conner Provins in Circuits > Arduino

52 Views, 0 Favorites, 0 Comments

2 Alternating Blinking LEDs With an Arduino

clignoter-2leds-single.png
IMG_20240827_110341.jpg

I created an Arduino Uno circuit with 2 LEDs that alternate blinking.


Instructor: Mr. Sweet

Source: Mechatronics 1 class (SparkFun SIK Kit)

Supplies

You will need:

  1. 1 Arduino Uno
  2. 1 power source (I used a Chromebook)
  3. Something to code on (I used a Chromebook)
  4. 1 cord to connect Arduino Uno to your power source
  5. 1 small breadbord
  6. 2 LEDs (I used red and yellow)
  7. 1 100 Ohm resistor (You can also do it with 2, but I won't show you how to do that in this instructable)
  8. 4 jumper wires (I recommend using black and red for negative and positive)

Connecting the LEDs and Resistor

IMG_20240827_111313.jpg

Place both LEDs in your breadboard as shown in the image, with the cathodes (the cathode is the long leg) on the outside and the anodes in the same hole on the inside. Then, place your resistor as shown in the image, with one end in the same hole as the LED anodes and the other end in a negative hole in the same column.

Wiring Your Circuit

IMG_20240827_111555.jpg
IMG_20240827_111935.jpg

First, connect a jumper wire to ground on the Arduino and to the hole directly to the right of the resistor in the negative row (image 1). Second, connect jumper wires from the LED cathodes to the 13 and 12 pins on the Arduino (I connected the red LED cathode to pin 13 and the yellow LED cathode to pin 12) (image 2).

Coding Your Circuit

First, open the Arduino website and create a new sketch. Enter this code exactly:

void setup() {

pinMode(13, OUTPUT);

pinMode(12, OUTPUT);


}

void loop() {

digitalWrite (13, HIGH);

delay(1000);

digitalWrite (13, LOW);

delay(1000);


digitalWrite (12, HIGH);

delay(1000);

digitalWrite (12, LOW);

delay(1000);

}

After that, press the check mark to compile your code. Once your code is compiled with no errors, you can upload it to your Arduino Uno. To do this, connect your Arduino to your power source/computer with the cord mention in the materials list. Once your Arduino is plugged in, press the "Detect Device" button above your code and select the port that your Arduino is connected to. Once your Arduino is connected, press the arrow to upload your code. After the code uploads, you should have 2 alternating blinking LEDS. Congratulations!