Arduino Nano Compatible LEDs

About: Omar Silva-Zapata is co-founder of Robo-Geek Inc.

In this tutorial we will learn how to flash 3 LEDs sequentially and simultaneously.

This tutorial is designed to be used with the Arduino Nano compatible Robo-Geek kits only.

Step 1: How LEDs (Light Emitting Diodes) Work

LEDs are great electronic components that make any project come alive. LEDs can be found everywhere from our TVs at home to traffic lights and billboard signs. Turning your first LED on and off with your Arduino is perhaps one of the most fun things to do. To learn more about how LED work, check out this great YouTube video and if you really want to know a lot more, check out the Wikipedia link below.

https://en.wikipedia.org/wiki/Light-emitting_diode

Step 2: The Circuit

Before working on this circuit, make sure you disconnect the USB cable from your laptop.

The wiring diagram for this circuit is displayed with a Fritzing diagram with a picture of the same circuit using similar color coding.

Important: Please note that the cables in your kit may be different colors so use this reference as a guide.

Three resistors are required - one for each LED. Use RED, YELLOW and GREEN LEDs.

1. Connect the GND pin to the blue line in the breadboard. This will give you a common ground for your circuit.

2. Connect one leg of your resistors to the ground and the other leg to one of the LED. Repeat for each LED as shown in the diagram.

3. Connect Pin 12 to the other leg of the RED LED.

4. Connect Pin 11 to YELLOW LED

5. Connect Pin 10 to GREEN LED.

Step 3: The Code - Sequential LED

This code is very simple. We turn each LED on and off; first the RED, then the YELLOW and finally the GREEN. This sequence is repeated every 6 seconds.

To make the code to work:

1. Create a new project by selecting New from the File menu.

2. Delete the code that comes by default.

3. Copy paste the code below

4. Check connections circuits from prior Step.

5. Connect the USB and upload your program.

int redPin = 12;
int yellowPin = 11; int greenPin = 10;

void setup() { // initialize Leds pinMode(redPin, OUTPUT); pinMode(yellowPin, OUTPUT); pinMode(greenPin, OUTPUT); }

void loop() { digitalWrite(redPin, HIGH); delay(1000); digitalWrite(redPin, LOW); delay(1000); digitalWrite(yellowPin, HIGH); delay(1000); digitalWrite(yellowPin, LOW); delay(1000);

digitalWrite(greenPin, HIGH); delay(1000); digitalWrite(greenPin, LOW); delay(1000);

}

Step 4: The Code: Simultaneous

Using the same circuit, as in prior step we will create a new program and this time we will turn on all LEDs simultaneously for 1 sec and then turn all LEDs off for 1 sec, this sequence will repeat every 2 seconds.

int redPin = 12;
int yellowPin = 11; int greenPin = 10;

void setup() { // initialize Leds pinMode(redPin, OUTPUT); pinMode(yellowPin, OUTPUT); pinMode(greenPin, OUTPUT); }

void loop() { digitalWrite(redPin, HIGH); digitalWrite(yellowPin, HIGH); digitalWrite(greenPin, HIGH); delay(1000);

digitalWrite(redPin, LOW); digitalWrite(yellowPin, LOW); digitalWrite(greenPin, LOW); delay(1000); }

Step 5: Troubleshooting

When troubleshooting:

1. Check if you have any error uploading the program. If so then check your program or the settings in Arduino.

2. If you have no errors uploading the program, then we must check the circuit. Double check you have wired the circuit properly - do this only while the circuit is disconnected. Do not move cables or components while your circuit is powered.

3. Check the orientation of the LED diode. Refer to this tutorial to ensure the LED is working: https://www.instructables.com/id/Arduino-Nano/

4. Still not working? Take a break. Sometimes when we are tired, we don't see obvious things. Once rested, come back repeat steps above and try again.

5. Rarely you may have a defective component or wired but it's possible.

If you are sure all the other steps were done properly, replace the micro-switch with another micro-switch and test again. If everything else fails and you feel you are really stuck, please e-mail us at info@robo-geek.ca with evidence you purchase the kit from Robo-Geek and pictures of your circuit or the error you are getting.

If you want to add a comment to this tutorial, remember ensure to read Instructables Be nice policy before commenting.

Step 6: Challenges

If you would like to challenge yourself and do more, we suggest:

1. Create a program that turns LEDs on sequentially RED, YELLOW, GREEN, then it turns off first the GREEN, then the YELLOW and finally RED. With this logic RED will be turn on the longest.

2. Add 3 more LEDs and create 2 rows, one that turns on sequentially and the other simultaneously.

Share

    Recommendations

    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Plastics Contest

      Plastics Contest

    4 Discussions

    0
    None
    FALAKA1

    Question 2 months ago

    I used led tower but led didn't work auduino softwer error your led is 7459bit
    And aurduino 32 to 256 bit what I do

    0
    None
    DoctorEvil30564

    Question 4 months ago

    this looks like a great instructable for me to follow to try my hand with on programming a elegoo Arduino nano board to control some LED lights on a pair of ecto-goggles I'm putting together.

    Is it possible to setup the code to add LEDs that will stay lit up in addition to having the ones that blink in the code?

    2 more answers
    0
    None
    osilva5DoctorEvil30564

    Answer 4 months ago

    Hi Dr

    Yes it’s definitely possible. If you want to turn leds just set them on high under setup but don’t turn them off. And for the LEDs that blink you do it in the loop section. Hope that helps

    0
    None
    DoctorEvil30564osilva5

    Reply 4 months ago

    OK two more questions, in order to power the arduino I'd need to connect the negative lead from my battery pack to the ground pin and then connect the positive lead to the 5V pin right? I bought several of the elegoo arduino nano clones to use so they may be different than the real arduino nano boards. Also is it possible to run a nano board using a 2xAA battery box enclosure as it outputs 3 volts instead of 5 volts? I ask because I tried soldering the leads to one of my nano clone boards and when I put the batteries in it it appears to power up, it shows the L led as blinking (as I haven't uploaded a sketch to it yet). I need to power 2 green LEDs to stay on while the arduino nano has power and then I want to hook up 3 more to create a random blinking effect to create a "power" bar on the inside of the lights. I'm ok with the LEDs being dim, as I need to be able to look through the lenses to see while I've got them on.