Building a Knight Rider LED Display with Arduino

Minhajnazeer
3 min readJan 21, 2024

--

Arduino to control 6 LEDs

Introduction:

In this project, we’ll explore how to create a Knight Rider-style LED display using Arduino. This classic effect involves a series of LEDs blinking in sequence from left to right and then right to left, creating a mesmerizing visual pattern. It’s a fun and engaging project for Arduino enthusiasts of all levels.

The Challenge:

The goal is to control six LEDs arranged in a line, mimicking the iconic Knight Rider car light. The LEDs will blink in a sequence, moving from left to right and then right to left, continuously when the Arduino is powered up.

Approach:

To achieve this, we will use the Arduino programming language and a simple circuit with six LEDs. The code will control the LEDs’ illumination in a specific sequence to replicate the Knight Rider effect.

Materials Needed:

  1. Arduino board (you can use the simulator at Tinkercad if you don’t have a physical board)
  2. 6 LEDs
  3. Jumper wires
  4. Breadboard
  5. Resistor (220–330 ohms)
  6. Computer with Arduino IDE installed

Step-by-Step Guide:

1. Set Up Your Arduino Environment:

Make sure you have the Arduino IDE installed on your computer. If not, you can download it from the official Arduino website.

2. Connect the Circuit:

Connect the LEDs to the Arduino board according to the provided code. Ensure you have the correct resistor in series with each LED. For a physical setup, use a breadboard and jumper wires. For the simulator, use the components available in the Tinkercad circuit editor.

3. Open Arduino IDE and Paste the Code:

Open the Arduino IDE, create a new sketch, and paste the provided Arduino code into the editor.

// Define the pin numbers for the LEDs
int ledPins[] = {2, 3, 4, 5, 6, 7};
int numLEDs = 6;

void setup() {
// Set all LED pins as OUTPUT
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT);
}
}

void loop() {
// Loop for left to right movement
for (int i = 0; i < numLEDs; i++) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}

// Loop for right to left movement
for (int i = numLEDs - 2; i > 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(100);
digitalWrite(ledPins[i], LOW);
}
}

4. Verify and Upload:

Verify the code for any errors by clicking on the checkmark icon. If no errors are found, upload the code to your Arduino board by clicking on the right-arrow icon.

5. Power Up:

Connect your Arduino to a power source. Whether you’re using a physical board or the simulator, power it up.

6. Observe the Knight Rider Effect:

Watch as the LEDs blink in a left-to-right and then right-to-left sequence, recreating the iconic Knight Rider car light pattern.

Tips and Troubleshooting:

  • Check Your Wiring: Ensure that the LEDs are connected to the correct pins on the Arduino and that the longer leg (positive) is connected to the pin and the shorter leg (negative) is connected to the ground (GND).
  • Adjust Pin Numbers: If your LED connections are different, modify the ledPins array in the code to match your setup.
  • Experiment with Delay: Feel free to experiment with the delay duration in the code to change the speed of the LED sequence.

Conclusion:

Congratulations! You’ve successfully created a Knight Rider LED display using Arduino. This project is a great introduction to programming and working with LEDs. Have fun experimenting with different LED arrangements and code modifications to customize your own light display.

--

--