Arduino knight rider circuit using led bargraph

In this post, we are going to make knight rider circuit using led bargraph. Led graph, it consists of 10 leds.

Stuff required:

  1. Arduino uno
  2. LED bargraph
  3. 220 ohm resistor
  4. connecting wires
Connections:

First of all, make connections as given in the diagram below:

connections
Source code:

Upload the code below to your arduino board

/* Code starts from here */

const int led[]={4,5,6,7,8,9,10,11,12,13},d=5;

void setup() {
  for(int i=0;i<10;i++)
    pinMode(led[i],OUTPUT);
}

void loop() {
  for(int i=0;i<10;i++)
    {
    digitalWrite(led[i],HIGH);
    delay(d);
    digitalWrite(led[i],LOW);
    }

  for(int j=0;j<8;j++)
    {
    digitalWrite(led[8-j],HIGH);
    delay(d);
    digitalWrite(led[8-j],LOW);
    }
}

/* Code ends here */

Hope, you had enjoyed this post. Thanks for reading this post.

Check out the video:


Stay tuned for more tutorials.




[original story: FunWithElectronics]