KNIGHT RIDER!

This is yet another combination of LED’s on Arduino UNO.

Hardware Required :-

  1. Arduino uno
  2. breadboard
  3. jumper wires
  4. Led’s
  5. 5 resistors of 330 ohm

Set of instructions that will govern your circuit :-

int pinArray[] = {2,3,4,5,6}; //create variables in an array mode by assigning the pin numbers to them
int count = 0; //  we created a variable count and assigned it avalue zero
int timer = 100; //we created a variable timer and assigned it a vlaue of 100

void setup()
{
for(count=0;count<5;count++)       // we have shortened the length of code by using the                                                                                     for loop in the code.
{
pinMode(pinArray[count], OUTPUT);
}
}

void loop()

{
for(count=0;count<5;count++)
{
digitalWrite(pinArray[count], HIGH);   //here too we have lessend the length of the                                                                                     code by using for loop so that we do    not have                                                                                        to type the same thing repeatedly.
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer);
}
for(count=5;count>=0;count–)
{
digitalWrite(pinArray[count], HIGH);
delay(timer);
digitalWrite(pinArray[count], LOW);
delay(timer);
}
}

How your circuit should look like :-

7

Notice here that the circuit is designed for 7 LED’s but we only require 5. So make to less connections just according to our code. Or you may change the code and make it for 7 LED’s just as the circuit.

For guys who do not want to use the for loop in the code and want to go to the basics of sequential programming i will also provide the code that do not uses for loop :-

int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int timer = 100;

void setup(){
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
  pinMode(pin5, OUTPUT);
  pinMode(pin6, OUTPUT);
  }

void loop() {
   digitalWrite(pin2, HIGH);
   delay(timer);
   digitalWrite(pin2, LOW);
   delay(timer);

   digitalWrite(pin3, HIGH);
   delay(timer);
   digitalWrite(pin3, LOW);
   delay(timer);

   digitalWrite(pin4, HIGH);
   delay(timer);
   digitalWrite(pin4, LOW);
   delay(timer);

   digitalWrite(pin5, HIGH);
   delay(timer);
   digitalWrite(pin5, LOW);
   delay(timer);

   digitalWrite(pin6, HIGH);
   delay(timer);
   digitalWrite(pin6, LOW);
   delay(timer);

   digitalWrite(pin6, HIGH);
   delay(timer);
   digitalWrite(pin6, LOW);
   delay(timer);

   digitalWrite(pin5, HIGH);
   delay(timer);
   digitalWrite(pin5, LOW);
   delay(timer);

   digitalWrite(pin4, HIGH);
   delay(timer);
   digitalWrite(pin4, LOW);
   delay(timer);

   digitalWrite(pin3, HIGH);
   delay(timer);
   digitalWrite(pin3, LOW);
   delay(timer);
}

We have successfully designed our knight rider circuit!

What you can variate here :-

Here there’s nothing much you can do but you can change the delay time of the led’s and blink them in accordance to your wish!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s