How to Control 8 Leds Using Arduino Uno

by Pranavthegreat in Circuits > Arduino

47939 Views, 19 Favorites, 0 Comments

How to Control 8 Leds Using Arduino Uno

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

Things U Need

07072012052.jpg
Intro-to-Arduino.jpg
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

Placing the Leds and Wiring

07072012054.jpg
07072012055.jpg
07072012057.jpg
07072012058.jpg
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 

Uploading the Code

07072012063.jpg

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);

}