20 LED Knight Rider-2 Using arduino mega

Knight Rider-2 simple project using Arduino Mega and 20 LEd.  This example makes use of 20 LEDs connected to the pins 22 – 41 on the board using 40 Ohm resistors and LED driver IC ULN2003. The code example will make the LEDs blink in a sequence, one by one.

Hardware Requirement

  • Arduino Mega
  • ULN2003 X 3 IC
  • 470 Ohms X 20 Resistors
  • Blue LED X 20

Download Arduino Code



Video Of The project


Arduino Code


/* Knight Rider
* Visit www.twovolt.com for Code , Circuit
* Hardware required>>>>Arduino Mega2560 , 20 LED board

*/

int pinArray[] = {22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};
int count = 0;
int timer = 10;

void setup(){
for (count=0;count<20;count++) {
pinMode(pinArray[count], OUTPUT);
}
}

void loop() {
for (count=0;count<19;count++) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count + 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
for (count=19;count>0;count–) {
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count – 1], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer*2);
}
}