In this tutorial I will show you how to make multiple LEDs blink with Arduino.  You will need three LEDs, jumper wires, breadboard, and Arduino.

Step 1: Program the Arduino

Now you will need to paste the following code into the Arduino software and upload it to the Arduino.

int led = 13;
int led2 = 12;
int led3 = 11;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
  pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT); 

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  {digitalWrite(led2, HIGH);
digitalWrite(led2, LOW);
{digitalWrite(led3, HIGH);
digitalWrite(led3, LOW);
delay(100);}// wait for a second

Step 2: Connecting GND

First connect a jumper wire from GND to the negative rail on the breadboard.

Step 3: Connecting the LEDs.

Then plug in the other jumper wires like this:
First, plug a wire from 13 on the Arduino to the top row on the breadboard.
Next, plug a wire from 12 on the Arduino to the top row on the breadboard.
Then plug a wire from 11 on the Arduino to the top row on the breadboard.
Space these out well. Use the picture to help you.
Now connect a wire going from the negative rail to the right of the other wires on the breadboard.
Lastly, put the longer leg of the Led (+) under the wire that goes to the Arduino. The shorter leg of the LED goes under the port that connects to the negative rail.

Step 4: Video of It Working

<p>Hi</p><p>Great Job Mate, I made a few changes to the code for 8 LEDs on a board,</p><p>Here's the code; Using the following pins 13,12,11,10,9,6,5,3 on Arduino UNO R3</p><p> int led = 13;</p><p>int led2 = 12;</p><p>int led3 = 11;</p><p>int led4 = 10;</p><p>int led5 = 9;</p><p>int led6 = 6;</p><p>int led7 = 5;</p><p>int led8 = 3;</p><p>// the setup routine runs once when you press reset:</p><p>void setup() { </p><p>// initialize the digital pin as an output.</p><p>pinMode(led, OUTPUT);</p><p>pinMode(led2, OUTPUT);</p><p>pinMode(led3, OUTPUT);</p><p>pinMode(led4, OUTPUT);</p><p>pinMode(led5, OUTPUT);</p><p>pinMode(led6, OUTPUT);</p><p>pinMode(led7, OUTPUT);</p><p>pinMode(led8, OUTPUT); </p><p>}</p><p>// the loop routine runs over and over again forever:</p><p>void loop() {</p><p>{digitalWrite(led, HIGH);</p><p>delay (15);</p><p>digitalWrite(led, LOW);</p><p>delay(15);</p><p>digitalWrite(led, HIGH);</p><p>delay(15);</p><p>digitalWrite(led, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led2, HIGH);</p><p>delay (15);</p><p>digitalWrite(led2, LOW);</p><p>delay(15);</p><p>digitalWrite(led2, HIGH);</p><p>delay(15);</p><p>digitalWrite(led2, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led3, HIGH);</p><p>delay (15);</p><p>digitalWrite(led3, LOW);</p><p>delay(15);</p><p>digitalWrite(led3, HIGH);</p><p>delay(15);</p><p>digitalWrite(led3, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led4, HIGH);</p><p>delay (15);</p><p>digitalWrite(led4, LOW);</p><p>delay(15);</p><p>digitalWrite(led4, HIGH);</p><p>delay(15);</p><p>digitalWrite(led4, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led5, HIGH);</p><p>delay (15);</p><p>digitalWrite(led5, LOW);</p><p>delay(15);</p><p>digitalWrite(led5, HIGH);</p><p>delay(15);</p><p>digitalWrite(led5, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led6, HIGH);</p><p>delay (15);</p><p>digitalWrite(led6, LOW);</p><p>delay(15);</p><p>digitalWrite(led6, HIGH);</p><p>delay(15);</p><p>digitalWrite(led6, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led7, HIGH);</p><p>delay (15);</p><p>digitalWrite(led7, LOW);</p><p>delay(15);</p><p>digitalWrite(led7, HIGH);</p><p>delay(15);</p><p>digitalWrite(led7, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led8, HIGH);</p><p>delay (15);</p><p>digitalWrite(led8, LOW);</p><p>delay(15);</p><p>digitalWrite(led8, HIGH);</p><p>delay(15);</p><p>digitalWrite(led8, LOW);</p><p>delay(15);</p><p>{digitalWrite(led8, HIGH);</p><p>delay (15);</p><p>digitalWrite(led8, LOW);</p><p>delay(15);</p><p>digitalWrite(led8, HIGH);</p><p>delay(15);</p><p>digitalWrite(led8, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led7, HIGH);</p><p>delay (15);</p><p>digitalWrite(led7, LOW);</p><p>delay(15);</p><p>digitalWrite(led7, HIGH);</p><p>delay(15);</p><p>digitalWrite(led7, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led6, HIGH);</p><p>delay (15);</p><p>digitalWrite(led6, LOW);</p><p>delay(15);</p><p>digitalWrite(led6, HIGH);</p><p>delay(15);</p><p>digitalWrite(led6, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led5, HIGH);</p><p>delay (15);</p><p>digitalWrite(led5, LOW);</p><p>delay(15);</p><p>digitalWrite(led5, HIGH);</p><p>delay(15);</p><p>digitalWrite(led5, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led4, HIGH);</p><p>delay (15);</p><p>digitalWrite(led4, LOW);</p><p>delay(15);</p><p>digitalWrite(led4, HIGH);</p><p>delay(15);</p><p>digitalWrite(led4, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led3, HIGH);</p><p>delay (15);</p><p>digitalWrite(led3, LOW);</p><p>delay(15);</p><p>digitalWrite(led3, HIGH);</p><p>delay(15);</p><p>digitalWrite(led3, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led2, HIGH);</p><p>delay (15);</p><p>digitalWrite(led2, LOW);</p><p>delay(15);</p><p>digitalWrite(led2, HIGH);</p><p>delay(15);</p><p>digitalWrite(led2, LOW);</p><p>delay(15);}</p><p>{digitalWrite(led, HIGH);</p><p>delay (15);}</p><p>digitalWrite(led, LOW);</p><p>delay(15);</p><p>digitalWrite(led, HIGH);</p><p>delay(15);</p><p>digitalWrite(led, LOW);</p><p>delay(15);}</p><p>}</p><p>H </p>
<p>how can I make two lights blink at the same time? </p>
<p>By the way you can also do it in a much simpler manner using delay(). <br><br>//turns on leds 3 and 4 for 500 millisec<br>digitalWrite(3, HIGH);<br>digitalWrite(4, HIGH);<br>delay(500);<br></p><p>//turns off leds 3 and 4 for 500 millisec<br>digitalWrite(3, LOW);<br>digitalWrite(4, LOW);<br>delay(500);</p>
<p>for this you will need to multitask. Look into the millis() function.<br><br>Search: aduino multitasking to learn more<br><br>here's the code:<br><br>class Flasher</p><p>{</p><p>// Class Member Variables</p><p>// These are initialized at startup</p><p>int ledPin; // the number of the LED pin</p><p>long OnTime; // milliseconds of on-time</p><p>long OffTime; // milliseconds of off-time</p><p>// These maintain the current state</p><p>int ledState; // ledState used to set the LED</p><p>unsigned long previousMillis; // will store last time LED was updated</p><p> // Constructor - creates a Flasher </p><p> // and initializes the member variables and state</p><p> public:</p><p> Flasher(int pin, long on, long off)</p><p> {</p><p>ledPin = pin;</p><p>pinMode(ledPin, OUTPUT); </p><p>OnTime = on;</p><p>OffTime = off;</p><p>ledState = LOW; </p><p>previousMillis = 0;</p><p> }</p><p> void Update()</p><p> {</p><p> // check to see if it's time to change the state of the LED</p><p> unsigned long currentMillis = millis();</p><p> if((ledState == HIGH) &amp;&amp; (currentMillis - previousMillis &gt;= OnTime))</p><p> {</p><p> ledState = LOW; // Turn it off</p><p> previousMillis = currentMillis; // Remember the time</p><p> digitalWrite(ledPin, ledState); // Update the actual LED</p><p> }</p><p> else if ((ledState == LOW) &amp;&amp; (currentMillis - previousMillis &gt;= OffTime))</p><p> {</p><p> ledState = HIGH; // turn it on</p><p> previousMillis = currentMillis; // Remember the time</p><p> digitalWrite(ledPin, ledState); // Update the actual LED</p><p> }</p><p> }</p><p>};</p><p>Flasher led1(12, 350, 350);</p><p>Flasher led2(13, 350, 350);</p><p>void setup()</p><p>{</p><p>}</p><p>void loop()</p><p>{</p><p>led1.Update();</p><p>led2.Update();</p><p>}<br><br>taken from: https://learn.adafruit.com/multi-tasking-the-arduino-part-1/a-classy-solution</p>
KFC is yummy<br>Kuam is yummy<br>Kuam is KFC<br><br>*dab
KFC is yummy<br>Kuam is Yummy<br>Kuam is KFC<br><br>*dab
<p>far more elegant</p><p>int led3 = 3;<br>int led4 = 4;<br>int led5 = 5;<br><br>// the setup routine runs once when you press reset:<br>void setup() { <br> // initialize the digital pin as an output.<br> pinMode(led3, OUTPUT);<br> pinMode(led4, OUTPUT);<br>pinMode(led5, OUTPUT); <br>}<br><br>// the loop routine runs over and over again forever:<br>void loop() {<br><br>for(int counter =3;counter&lt;=6;counter++){<br>digitalWrite(&quot;led&quot;+counter, HIGH);<br> delay(100); <br> digitalWrite(&quot;led&quot;+counter, LOW); <br> delay(100); <br> }<br><br>}</p>
<p>It says error.. (T_T)</p>
<p>This is my first project ever with Arduino or anything hardware related. Thanks so much! Super pumped to level up. </p>
<p>Hey,</p><p>I am using Arduino with RTC to operate the lights of my home.</p><p>I want at 10 PM all my lights should OFF and at 6 AM same should be ON.</p><p>I have completed everything but only unable to tell Arduino to read time from RTC to operate lights.</p><p>Can it be done by reading Arduino Serial Monitor? If yes, then HOW.</p><p>Also the other possible method to do same through Arduino.</p><p>Thanks.</p>
<p> Thanks for sharing! This is one of my first projects with my Arduino and it went really well.</p>
<p>Develop a reaction game for two players. The game starts with<br>both LEDs on. After a random time (between 1 and 10 seconds) both LEDs go off<br>and the board waits for one of the buttons to be clicked. The goal of both<br>players is to press their button as fast as possible after they see the LEDs<br>turned off. The faster player wins and the appropriate LED is turned on (for 5<br>seconds) to show the winner. Then both LEDs are turned on and the game repeats.</p><p>there is any body now how can do it</p>
<p>Perhaps you can help me</p><p>Im looking for code that will switch an LED on then off withing a single loop</p><p>without using the delay() function. Everywhere I look there are modified versions of the 'blink without delay' however they all have the same issue</p><p>loop starts the use millis() and a few variable to check the state if its high or low then swop the state over but only swops it once so the loop runs it switches on then the loop has to run a second time before it switches off. Any ideas?</p>
<p>This example will blink multiple LEDs all at different rates. </p><p><a href="http://oosmos.com/examples/blink" rel="nofollow">http://oosmos.com/examples/blink </a> </p>
<p><a href="http://arduino.cc/en/Reference/analogWrite" rel="nofollow">http://arduino.cc/en/Reference/analogWrite</a></p><p>using the analog pins should help with your problem.</p>
thanks for sharing the code. I'm new to arduino programing. I'm able to run this program successfully.
<p>Thanks for the interesting photo. Could you tell us what programming board is that?</p><p>Can you share the wirings too?</p>
<p>Do you know how to do it in a forLoop? If so can post the code</p>
<p>are you not using resistors on your leds</p>
<p>Thanks man! I add 3 more LEDs and it works great!!</p>
great to see my first arduino project being supported by instructables
<p>if the video is private why are you posting the youtube link here ? is it to show us the black screen ? thanks for sharing</p>
Oops sorry about that. I fixed it.
<p>It dos not work. why?</p>
<p>thanks for your help!!</p>
<p>i've modified your code, just a little bit here is:</p><p>int led = 13;<br>int led2 = 12;<br>int led3 = 11;<br><br>// the setup routine runs once when you press reset:<br>void setup() { <br> // initialize the digital pin as an output.<br> pinMode(led, OUTPUT);<br> pinMode(led2, OUTPUT);<br>pinMode(led3, OUTPUT); <br>}<br><br>// the loop routine runs over and over again forever:<br>void loop() {<br>digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)<br>delay(100); // wait for a second<br>digitalWrite(led, LOW); // turn the LED off by making the voltage LOW<br>delay(1000); <br>digitalWrite(led, HIGH);<br>delay(100); <br>digitalWrite(led, LOW);<br>delay (1000);<br>{digitalWrite(led2, HIGH);<br>delay(100);<br>digitalWrite(led2, LOW);<br>delay(1000);<br>digitalWrite(led2, HIGH);<br>delay(100);<br>digitalWrite(led2, LOW);<br>delay(1000);}<br>{digitalWrite(led3, HIGH);<br>delay(100);<br>digitalWrite(led3, LOW);<br>delay (1000);<br>digitalWrite(led3, HIGH);<br>delay(100);<br>digitalWrite(led3, LOW);<br>delay(1000);}// wait for a second<br>digitalWrite(led2, HIGH);<br>delay(100); <br>digitalWrite(led2, LOW);<br>delay (100);<br>digitalWrite(led2, HIGH);<br>delay(100); <br>digitalWrite(led2, LOW);<br>delay (100);<br>{digitalWrite(led, HIGH);<br>delay(100);<br>digitalWrite(led, LOW);<br>delay(100);<br>digitalWrite(led, HIGH);<br>delay(100);<br>digitalWrite(led, LOW);<br>delay(100);}<br>{digitalWrite(led3, HIGH);<br>delay(100);<br>digitalWrite(led3, LOW);<br>delay (100);<br>digitalWrite(led3, HIGH);<br>delay(100);<br>digitalWrite(led3, LOW);<br>delay(100);}<br>}</p>
<p>its really works!! thanks, but i think you should add the resistors to the led. i using 220k resistor and 3 different leds,</p>
<p>Hi, could you explain why we would list int led = 13; and not int led 1 = 13<br>I know default 13 is a blink led , is that why ?<br>Can we use 13 for other things , what do we have to do different while addressing pin 13?<br>Thanks.</p><p>int led = 13;<br> int led2 = 12;<br> int led3 = 11;</p>
<p>worked! thanks</p>
I would just like to say I hope you know the comments are incorrect about the length of time the delays are. <br> <br>The delay you have it set to is to delay for 1/10 of a second
Thanks! Glad it worked.
Thanks! This is explained perfectly, this is my first aduino project ever and it turned out beautifully!

About This Instructable




More by The Electrodog Show:Checking Battery Status on Mediatek LinkIt One Checking Your Current Location With MediaTek LinkIT One Controling Low Voltage Devices with MediaTek LinkIt One 
Add instructable to: