loading

This instructable coversssets of instructions for using a microcontroller, called the Arduino Uno to create various lighting sequences on light emitting diodes, more popularly known as LEDs. The instructions below cover all the main steps of the process.

Step 1: Acquire Components and Parts.

The components requires for this project involvve; Eight LEDs, Ten jumper wires, a breadboard, Eight 330ohm resistors, an Arduino micro controller and its connecting cable and finally a working computer. And have the drawn circuit close by for direct reference while building.

Step 2: Connecting the Resistors.

Have the breadboard laying on a flat surface to enable solid connections.The breadboard has signs for positive (as in power) and negative (as in ground) connections. Place the resistors on the breadboard, with one leg in the negative column(ground) of the breadboard and the other leg in a different hole located somewhere else on the breadboard.

Step 3: Connecting the LEDs.

For each LED, connect the negative side (shorter leg) of the LED into the same row of a resistor. Not on the same row as the negative column but on the same row as the other leg of the resistor. Then connect the positive side (longer leg) of the LED into other holes in a different column and row on the breadboard

Step 4: Connecting the LEDs to the Arduino Microcontroller.

For each LED connect the positive side(longer leg) to digital pins on the Arduino using jumper wires. Connect one end of the wire to the same row of the positive side of the LED and connect the other side of the wire to digital pins. There are a total of eight LEDs on the breadboard therefore connect wires from eight positive LED sides to digital pins two through nine (in no particular order).

Step 5: Providing Power and Ground Connections.

As earlier explained, power needs to be supplied to the breadboard and the ground connection also needs to be made. Place one end of a jumper cables into the hole on the top column marked with the positive sign on the breadboard and then connect the other end to the pin labeled 5V on the Arduino. And then connect one side of another jumper wire to the top hole of the negative column on the breadboard and the other end of the wire to a pin labelled GND (ground) on the Arduino.

Step 6: Connect the Arduino Onto the Computer.

Connect the Arduino to the computer using the black USB cable that comes with the Arduino.

Step 7: Download the Arduino Application for Your Version of Computer and the Correct Drivers.

Download the Arduino application for the version of computer you have (windows, Mac, Linux) from the Arduino website. Install the drivers by following the online instructions found on the

http://arduino.cc/en/Guide/Windows for windows.

http://arduino.cc/en/Guide/MacOSX for Mac

Step 8: Adjusting the Settings.

Select the correct microcontroller board by looking at the top left hand corner of the arduino sketch page and then going to tools->boards->and the selecting Arduino Uno. And then select the correct serial port by going to tools->Serial->COM3.

Step 9: Paste the Code Below Onto an Open Arduino "sketch".

NOTE: The lines starting with // are comment sections, they are only used to explain the code and they don’t contribute to the actual code!

int ledPins[] = {2,3,4,5,6,7,8,9};

// The first element of an array is index 0.

// We've put the value "2" in index 0, "3" in index 1, etc.

// The final index in the above array is 7, which contains

// the value "9".

// We're using the values in this array to specify the pin numbers

// that the eight LEDs are connected to. LED 0 is connected to

// pin 2, LED 1 is connected to pin 3, etc.

void setup()

{

int index;

// In this sketch, we'll use "for() loops" to step variables from

// one value to another, and perform a set of instructions for

// each step. For() loops are a very handy way to get numbers to

// count up or down.

// Every for() loop has three statements separated by

// semicolons (;):

// 1. Something to do before starting

// 2. A test to perform; as long as it's true, keep looping

// 3. Something to do after each loop (increase a variable)

// Here we'll use a for() loop to initialize all the LED pins

// to outputs. This is much easier than writing eight separate

// statements to do the same thing.

// This for() loop will make index = 0, then run the pinMode()

// statement within the brackets. It will then do the same thing

// for index = 2, index = 3, etc. all the way to index = 7.

for(index = 0; index <= 7; index++)

{

pinMode(ledPins[index],OUTPUT);

// ledPins[index] is replaced by the value in the array.

// For example, ledPins[0] is 2

}

}

void loop()

{

// This loop() calls functions that we've written further below.

// We've disabled some of these by commenting them out (putting

// "//" in front of them). To try different LED displays, remove

// the "//" in front of the ones you'd like to run, and add "//"

// in front of those you don't to comment out (and disable) those

// lines.

oneAfterAnotherNoLoop(); // Light up all the LEDs in turn

}

/*

oneAfterAnotherNoLoop()

This function will light one LED, delay for delayTime, then light

the next LED, and repeat until all the LEDs are on. It will then

turn them off in the reverse order.

This function does NOT use a for() loop. We've done it the hard way

to show you how much easier life can be when you use for() loops.

Take a look at oneAfterAnotherLoop() further down, which does

exactly the same thing with much less typing.

*/

void oneAfterAnotherNoLoop()

{

int delayTime = 100; // time (milliseconds) to pause between LEDs

// make this smaller for faster switching

// turn all the LEDs on:

digitalWrite(ledPins[0], HIGH); //Turns on LED #0 (pin 2)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[1], HIGH); //Turns on LED #1 (pin 3)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[2], HIGH); //Turns on LED #2 (pin 4)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[3], HIGH); //Turns on LED #3 (pin 5)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[4], HIGH); //Turns on LED #4 (pin 6)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[5], HIGH); //Turns on LED #5 (pin 7)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[6], HIGH); //Turns on LED #6 (pin 8)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[7], HIGH); //Turns on LED #7 (pin 9)

delay(delayTime); //wait delayTime milliseconds

// turn all the LEDs off:

digitalWrite(ledPins[7], LOW); //Turn off LED #7 (pin 9)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[6], LOW); //Turn off LED #6 (pin 8)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[5], LOW); //Turn off LED #5 (pin 7)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[4], LOW); //Turn off LED #4 (pin 6)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[3], LOW); //Turn off LED #3 (pin 5)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[2], LOW); //Turn off LED #2 (pin 4)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[1], LOW); //Turn off LED #1 (pin 3)

delay(delayTime); //wait delayTime milliseconds

digitalWrite(ledPins[0], LOW); //Turn off LED #0 (pin 2)

delay(delayTime); //wait delayTime milliseconds

}

Step 10: Upload Onto Arduino.

Make sure the serial port is set to COM3 and the correct board is selected, that is Arduino uno is selected from the dropdown menu at the top left corner of the arduino application. Then upload the code unto the board by clicking upload at the top left corner.

Step 11: Watch the Magic.

<p>Can you re-post the video so it's not private?? Trying to learn this for an art installation I'm working on(:</p>
<p>Great Arduino project. You should enter this in the Arduino All the Things contest.</p>

About This Instructable

6,273views

84favorites

More by Joshua-Danjuma:Controlling Multiple LEDs with an Arduino Uno. 
Add instructable to: