Home > Driving Displays, Exploring Ideas > Arduino Knight Rider LED Scanner Bar

Arduino Knight Rider LED Scanner Bar

Driving 8 Leds to simulate the the Knight Rider car of the TV show.
A very simple algorithm was implemented.


Image

The Sketch:

/*
KnightR8L.pde
Arduining.com 1 MAY 2011
Driving 8 Leds to emulate the Knight Rider car.
Leds connected to the digital pins (0~7).
*/
byte n=0;       //The number to be displayed (8 bits).

void setup(){
  for(int i=0;i<8;i++){  // Digital pins 0~7 as outputs. 
    pinMode(i,OUTPUT);
  }
}

void loop(){
  for(n=1;n<128;n = n << 1){
    PORTD= n;
    delay(132);
//    delay(analogRead(0)/4);
  }
  for(n=128;n>1;n = n >> 1){
    PORTD= n;
    delay(132);
//    delay(analogRead(0)/4);
  }
}

A potentiometer was used to adjust the scanning frequency.
A delay dependent of the analog input 0 was used.This part is commented in the final code.

See the Youtube Video:

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: