How to Control 8 Leds Using Arduino Uno

About: I was 13 when I made this account so please don't make fun of my username

hey guys this is my first arduino project  plz  comment how u feel.       

Step 1: Things U Need

As this is easy project for beginner's so parts are also simple 
Parts:
1- Arduino uno or any other board will work
1-Beardboard
9- jumper wires or wires will also do 
8 -leds any color u like i used 3 red, 3 green and 2 blue
8- 1k resistors

Step 2: Placing the Leds and Wiring

In this step u have to place the leds on the bread board i have kept the positive  wire on the right side . 
Next wire them as shown in 

Step 3: Uploading the Code

int ledPins[] = {2,3,4,5,6,7,8,9};
int delayTime = 100; void setup() { for(int i = 0; i < 8; i++) pinMode(ledPins[i],OUTPUT);

}

void loop() { digitalWrite(ledPins[0], HIGH);

delay(delayTime);

digitalWrite(ledPins[1], HIGH);

delay(delayTime);

digitalWrite(ledPins[2], HIGH);

delay(delayTime);

digitalWrite(ledPins[3], HIGH);

delay(delayTime);

digitalWrite(ledPins[4], HIGH);

delay(delayTime);

digitalWrite(ledPins[5], HIGH);

delay(delayTime);

digitalWrite(ledPins[6], HIGH);

delay(delayTime);

digitalWrite(ledPins[7], HIGH);

delay(delayTime);

//Turns Each LED Off

digitalWrite(ledPins[7], LOW);

delay(delayTime);

digitalWrite(ledPins[6], LOW);

delay(delayTime);

digitalWrite(ledPins[5], LOW);

delay(delayTime);

digitalWrite(ledPins[4], LOW);

delay(delayTime);

digitalWrite(ledPins[3], LOW);

delay(delayTime);

digitalWrite(ledPins[2], LOW);

delay(delayTime);

digitalWrite(ledPins[1], LOW);

delay(delayTime);

digitalWrite(ledPins[0], LOW);

delay(delayTime);

}

Share

    Recommendations

    • PCB Contest

      PCB Contest
    • Big and Small Contest

      Big and Small Contest
    • Toys Contest

      Toys Contest

    7 Discussions

    0
    None
    rvenegas1

    4 years ago on Introduction

    If you are going to put something out for people to try, then your instructions need to be more specific. The pictures are blurry and you don't really explain how to connect the LEDs, resistors, and wires. The code is also giving me 5 errors, I tried the code that maewert put out for the binary name and his worked. Not trying to put you down, but the steps aren't that great to follow.

    0
    None
    mathesen1097

    5 years ago

    This is pretty awesome, I was going to use the code you inserted to make a project. It is a little led dome that changes color. I am using my ardunio for the first time. I'll post it soon with my fingers crossed that it works.

    1 reply
    0
    None
    maewertClyde2013

    Reply 5 years ago on Introduction

    Try this:

    /*
      SpellMyName
      Turns on 8 LEDs to spell my name in Binary
    */

    // Pins 2-9 have my 8 LEDs connected to spell my name
    int led[8] = {2,3,4,5,6,7,8,9};

    // MyNameLength holds the length of my name in characters
    #define MyNameLength 4
    char name[MyNameLength]= {'M','a','r','k'};

    // the setup routine runs once when you press reset:
    void setup()
    {               
      // initialize the digital pin as an output.
      int i;
      for (i=0;i<8;i++)
      {
        pinMode(led[i], OUTPUT);    
      }
    }

    /*
      LightUp routine lights up the 8 LEDs to spell out in binary the letter passed in
    */
    void LightUp(char letter)
    {
      int i;
      for (i=0;i<8;i++)
      {
        // lets check the bit to see if it is on or off
        if ((letter&(1<<i))!=0)
        {
          digitalWrite(led[i],HIGH);
        }
        else
        {
          digitalWrite(led[i],LOW);
        }
      }
    }

    // the loop routine runs over and over again forever:
    void loop()
    {
      int i;
     
      for (i=0;i<MyNameLength;i++)
      {
        LightUp(name[i]);
        delay(1000);               // wait for a second
      }
    }