Build it step by step
0 of 6 donePlace the LEDs
Push eight LEDs in a row on the breadboard, all short legs towards the ground rail.
Add the resistors
Put a 220 Ω resistor between each long leg and its own wire to D2 to D9.
Wire the ground
Join the ground rail to Nano GND.
Add the speed pot
Outer pins to 5V and GND, middle pin to A0.
Upload and run
Upload the sketch. The bright dot should sweep with a fading tail.
Tune it
Turn the pot for speed. Change the 3 in the fade line for a longer or shorter tail.
How do you build a knight Rider LED scanner?
Eight LEDs sweep back and forth with a fading tail, like the scanner on a famous TV car, with a pot that sets the speed. You need Arduino Nano, LED 5 mm red × 8, Resistor 220 Ω × 8, Potentiometer 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 45 minutes.
- Level
- Beginner
- Time
- About 45 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Nano × 1
- SemiconductorsBuyLED 5 mm red × 8
- PassivesBuyResistor 220 Ω × 8
- PassivesBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| LED 1 to LED 8 anodes (long legs) | Nano D2 to D9, each through a 220 Ω resistor | One pin per LED |
| All LED cathodes (short legs) | Nano GND | Common ground rail |
| Pot outer pins | Nano 5V and GND | Speed control supply |
| Pot middle pin | Nano A0 | Speed reading |
Code
Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). No libraries. The fast loop gives the PWM, so avoid delay() anywhere in it.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const byte pins[8] = {2, 3, 4, 5, 6, 7, 8, 9};
byte level[8]; // brightness 0 to 15 for each LED
int pos = 0, dir = 1;
unsigned long lastStep = 0;
byte phase = 0;
void setup() {
for (byte i = 0; i < 8; i++) pinMode(pins[i], OUTPUT);
}
void loop() {
unsigned int stepMs = map(analogRead(A0), 0, 1023, 20, 150);
if (millis() - lastStep >= stepMs) {
lastStep = millis();
for (byte i = 0; i < 8; i++) level[i] = level[i] > 3 ? level[i] - 3 : 0; // fade the tail
level[pos] = 15; // bright head
pos += dir;
if (pos == 7 || pos == 0) dir = -dir; // bounce at the ends
}
phase = (phase + 1) & 15; // software PWM, 16 steps
for (byte i = 0; i < 8; i++) digitalWrite(pins[i], level[i] > phase);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Pot at minimum | The sweep is fast, about one pass in 160 ms |
| Pot at maximum | The sweep is slow, about one pass in 1.2 s |
| Look at the tail | Two or three LEDs behind the head are dimmer |
| Each LED with the sketch stopped | Lights fully when its pin is driven HIGH |
If it does not work
One LED never lights
It is the wrong way round or its resistor is not in the row. Flip it and check the wire to its pin.
No fading, LEDs just blink
A delay() was added to the loop, which slows the software PWM. Remove it.
The tail flickers
The loop is too slow. Avoid Serial printing inside loop.
Speed does not change
Check the pot's middle pin goes to A0 and the outer pins to 5V and GND.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the knight Rider LED scanner?
Arduino Nano, LED 5 mm red × 8, Resistor 220 Ω × 8, Potentiometer 10 kΩ, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the knight Rider LED scanner take to build?
About 45 minutes for a beginner maker, in 6 steps.
How do I know the knight Rider LED scanner works?
Pot at minimum: The sweep is fast, about one pass in 160 ms. Pot at maximum: The sweep is slow, about one pass in 1.2 s. Look at the tail: Two or three LEDs behind the head are dimmer.
One LED never lights: what should I check?
It is the wrong way round or its resistor is not in the row. Flip it and check the wire to its pin.
No fading, LEDs just blink: what should I check?
A delay() was added to the loop, which slows the software PWM. Remove it.
The tail flickers: what should I check?
The loop is too slow. Avoid Serial printing inside loop.
Speed does not change: what should I check?
Check the pot's middle pin goes to A0 and the outer pins to 5V and GND.
