[Project 4] – Arduino Knight Rider With 8 LED

In this project we will make knight rider with 8 LED. I will use arduino uno in the circuit design program.I use usually arduino mega 2560.  You can use the other arduino cards. This project for beginners. Good Luck.Project 4 knight rider  

Schema:


 

Project 4 knight rider schema  

Materials:


Arduino UNO / Other Arduino Cards    x 1
Breadboard      x 1
220 ohm resistor    x 8
LED    x 8 
Jumper Cable

 

Program 1:


// letsarduino.com
// [Project 4] - Arduino Knight Rider With 8 LED

int ledPin1 = 13; 
int ledPin2 = 12;
int ledPin3 = 11;
int ledPin4 = 10;
int ledPin5 = 9;
int ledPin6 = 8;
int ledPin7 = 7;
int ledPin8 = 6; 
const int delayTime = 50; 

 void setup () 
 
{
 pinMode(ledPin1, OUTPUT); 
 pinMode(ledPin2, OUTPUT); 
 pinMode(ledPin3, OUTPUT); 
 pinMode(ledPin4, OUTPUT); 
 pinMode(ledPin5, OUTPUT); 
 pinMode(ledPin6, OUTPUT); 
 pinMode(ledPin7, OUTPUT); 
 pinMode(ledPin8, OUTPUT);
} 


 void loop() { 
 
 
 digitalWrite(ledPin1,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin1,LOW); // LED OFF

 digitalWrite(ledPin2,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin2,LOW); // LED OFF
 
 digitalWrite(ledPin3,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin3,LOW); // LED OFF
 
 digitalWrite(ledPin4,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin4,LOW); // LED OFF
 
 digitalWrite(ledPin5,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin5,LOW); // LED OFF
 
 digitalWrite(ledPin6,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin6,LOW); // LED OFF
 
 digitalWrite(ledPin7,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin7,LOW); // LED OFF
 
 digitalWrite(ledPin8,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin8,LOW); // LED OFF
 
 //turn
 
 digitalWrite(ledPin8,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin8,LOW); // LED OFF

 digitalWrite(ledPin7,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin7,LOW); // LED OFF
 
 digitalWrite(ledPin6,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin6,LOW); // LED OFF
 
 digitalWrite(ledPin5,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin5,LOW); // LED OFF
 
 digitalWrite(ledPin4,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin4,LOW); // LED OFF
 
 digitalWrite(ledPin3,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin3,LOW); // LED OFF
 
 digitalWrite(ledPin2,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin2,LOW); // LED OFF
 
 digitalWrite(ledPin1,HIGH); // LED ON
 delay(delayTime); 
 digitalWrite(ledPin1,LOW); // LED OFF
 
}

Program 2:


int ledPin1 = 13; 
int ledPin2 = 12;
int ledPin3 = 11; 
int ledPin4 = 10;
int ledPin5 = 9; 
int ledPin6 = 8; 
int ledPin7 = 7; 
int ledPin8 = 6; 
const int delayTime = 50; 
int pinArray[] = {6, 7, 8, 9, 10, 11, 12, 13};
int count = 0;
void setup () 
{ 
 pinMode(ledPin1, OUTPUT); 
pinMode(ledPin2, OUTPUT); 
pinMode(ledPin3, OUTPUT); 
pinMode(ledPin4, OUTPUT); 
pinMode(ledPin5, OUTPUT); 
pinMode(ledPin6, OUTPUT); 
pinMode(ledPin7, OUTPUT); 
pinMode(ledPin8, OUTPUT); 
} 
void loop() { 
 for (count=0;count<8;count++) {
 digitalWrite(pinArray[count], HIGH);
 delay(delayTime);
 digitalWrite(pinArray[count], LOW);
 delay(delayTime);
 }
 for (count=7;count>=0;count--) {
 digitalWrite(pinArray[count], HIGH);
 delay(delayTime);
 digitalWrite(pinArray[count], LOW);
 delay(delayTime);
 }
}

Project Related Images:


 

20141126_15191420141126_151931



 

You may also like...