Recreate the LED animation of K.I.T.T. from the Knight Rider TV series with a potentiometer.
We will make Knight Rider car led animation with a potentiometer
![](https://static.wixstatic.com/media/0f415a_58963a7862054ec19c122856d8b69dde~mv2.gif/v1/fill/w_800,h_450,al_c,pstr/0f415a_58963a7862054ec19c122856d8b69dde~mv2.gif)
We all remember the technological car in the iconic television series Knight Rider. The most important feature of this car is that the LEDs on the front of the car are constantly turn on one by one.
![](https://static.wixstatic.com/media/0f415a_431accbb72424fe7a3752d3d3ec4cf06~mv2.jpg/v1/fill/w_980,h_551,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/0f415a_431accbb72424fe7a3752d3d3ec4cf06~mv2.jpg)
For those who are new in Arduino and want to learn to code, it's time to learn how to make this animation with pot!
![](https://static.wixstatic.com/media/0f415a_bc683f6776c54068b3bd4cf6be35af9a~mv2.jpg/v1/fill/w_980,h_653,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/0f415a_bc683f6776c54068b3bd4cf6be35af9a~mv2.jpg)
Don't mess with breadboard circuits for learning Arduino and coding, just connect the cables and start coding right now!
Meet the Circle Electronic NOOB Series Knight Rider!
![](https://static.wixstatic.com/media/0f415a_a1c7c09e3455458bacf156adbe13338a~mv2.jpg/v1/fill/w_980,h_575,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/0f415a_a1c7c09e3455458bacf156adbe13338a~mv2.jpg)
![](https://static.wixstatic.com/media/0f415a_8b656204f7204cdc93d943969beab029~mv2.jpg/v1/fill/w_800,h_570,al_c,q_85,enc_avif,quality_auto/0f415a_8b656204f7204cdc93d943969beab029~mv2.jpg)
What can you do?
-You can connect each of the 8 separate leds to the Arduino pin and make each one turn on, in turn, using the for loop.
-Thanks to the buzzer on top, you can play Knight Rider theme song and learn how to make melodies using the buzzer.
-You can learn how to program 74HC593 Led driver IC. This integrated allows you to use 8 leds with only 3 connections. You can use this IC in other projects to use the motor or anything instead of using a led.
![](https://static.wixstatic.com/media/0f415a_bc57186f0c3a449eb7df4509ac034234~mv2.gif/v1/fill/w_800,h_449,al_c,pstr/0f415a_bc57186f0c3a449eb7df4509ac034234~mv2.gif)
Knight Rider Circuit Animation
How to make this animation with pot?
![](https://static.wixstatic.com/media/0f415a_a4dd9ac7c27b4e358ab47a2b6ec36369~mv2.jpg/v1/fill/w_484,h_416,al_c,q_80,enc_avif,quality_auto/0f415a_a4dd9ac7c27b4e358ab47a2b6ec36369~mv2.jpg)
We will use 74hc595 Shift Register in this project.
So, how to make this animation with shift register.
#define DATA 8
#define LATCH 9
#define CLOCK 10
static int led = 0;
byte number[23] = {0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001110,
0b00011100,
0b00111000,
0b01110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b01110000,
0b00111000,
0b00011100,
0b00001110,
0b00000111,
0b00000011,
0b00000001,
0b00000000
};
void setup() {
pinMode(CLOCK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(LATCH, OUTPUT);
}
void loop() {
static unsigned long time = millis();
if (millis() - time >= 80 && led <= 22) {
time = millis();
led++;
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, number[led]);
digitalWrite(LATCH, HIGH);
}
if (led == 22) {
led = 0;
}
}
This is our code to make this animation with 74hc595. We will change this to make this with pot.
We change it like it:
#define DATA 8
#define LATCH 9
#define CLOCK 10
byte number[] = {0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001110,
0b00011100,
0b00111000,
0b01110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
};
void setup() {
pinMode(CLOCK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(LATCH, OUTPUT);
}
void loop() {
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, number[*]);
digitalWrite(LATCH, HIGH);
}
Now we will read the data from pot
We will connect the pot middle pin to arduino analog 0 pin and read the datas
int pot=A0;
void setup() {
pinMode(pot,INPUT);
}
void loop() {
int potvalue = analogRead(pot);
}
![](https://static.wixstatic.com/media/0f415a_66c9b7e651164d7e80ea8bf534885cab~mv2.png/v1/fill/w_736,h_202,al_c,q_85,enc_avif,quality_auto/0f415a_66c9b7e651164d7e80ea8bf534885cab~mv2.png)
These are the data we get after making the connection. When we change the potentiometer, we read a value in the range 0-1023. We have to convert these values to 0-11.
We will use the map command to do this:
potvalue= map(potvalue,0,1023,0,11);
Now we are changing our code:
#define DATA 8
#define LATCH 9
#define CLOCK 10
int pot=A0;
byte number[] = {0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001110,
0b00011100,
0b00111000,
0b01110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
};
void setup() {
pinMode(CLOCK, OUTPUT);
pinMode(DATA, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(pot,INPUT);
}
void loop() {
int potvalue = analogRead(pot);
potvalue= map(potvalue,0,1023,0,11);
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, number[potvalue]);
digitalWrite(LATCH, HIGH);
}
That's it!
Our Website: https://www.circleelectronic.com
Github Page: https://github.com/circleelectronic/Knight-Rider
Tinkercad Project Link: https://www.tinkercad.com/things/6KD66LWNaAa
Knight Rider Product Link: https://www.circleelectronic.com/knight-rider
Tindie Product Link: https://www.tindie.com/products/circle/knight-rider/
Watch Knight Rider Circuit Video
Comments