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
Things U Need
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
Next wire them as shown in
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);
}