Knight Rider Light Pattern: LED Light moving in a line back and forth

 

Description: A row of LEDs controlled by an Arduino Nano blink back and forth creating what is known as the Knight Rider Effect. It was made popular in the TV Series Knight Rider, where an AI car showed off the flashy LED light effect.

Notes: In order to control the speed of the light, making it faster or slower, see this post on how to add a potentiometer.

Supplies:

1 – Breadboard 830 Points
1 – Arduino Nano
7 – LEDs
7 – 220 Ohm Resistors

Arduino Code:

void setup() {

  for (int i = 2; i < 10; i++) {
  pinMode(i, OUTPUT);
  
}
}

void LEDsOff(void)  {
  
  for (int i = 2; i < 10; i++) {
  digitalWrite(i, LOW);

}
}

void loop() {

  for (int i = 2; i < 8; i++) {
  LEDsOff();
  digitalWrite(i, HIGH);
  delay(110);
  
}

for (int i = 8; i > 2; i--) {
LEDsOff();
digitalWrite(i, HIGH);
delay(110);
}
}

Leave a Comment

− 5 = 2