University
Published

# Knight Rider LED Scanner Bar

Recreate Kitt's iconic front-mounted scanner bar as seen on the Knight Rider TV show from the 1980s.

BeginnerShowcase (no instructions)95

## Things used in this project

### Hardware components

×2
 Texas Instruments 74HC595 Shift Register
×2
 Capacitor 22 µF
×1
 Resistor 220 ohm
×16
 5 mm LED: Red
×16
 Arduino UNO & Genuino UNO
×1

## Schematics

Wire up the circuit as shown in the diagram below.

## Code

### Knight Rider Sketch

Arduino
```/***************************************************
* Knight Rider 74HC595 LED flasher
*
* Code that simulates Kitt's front mounted scanner bar.
*
* Author: Mario Gianota June 2020
*/
#define LATCH_PIN 8   // Connects to 74HC595 latch clock (pin 12)
#define CLOCK_PIN 12  // Connects to 74HC595 register clock (pin 14)
#define DATA_PIN 11   // Connects to 74HC595 data input (pin 11)

uint16_t buffer = 32768 + 16384 + 8192 + 4096;  // This creates a 16 bit number with the 4 top bits set to 1
// The bits in the buffer are shifted left and right to create the
// effect.
bool dir = 0;         // Direction to shift light pattern 0 = right, 1 = left

void setup() {
pinMode(LATCH_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(DATA_PIN, OUTPUT);
}

void loop() {
// Take latch pin low so that the LEDs don't change
// whilst we are latching in bits
digitalWrite(LATCH_PIN, LOW);

if( dir == 0 ) {
if( buffer == 15 ) {
// switch direction
dir = 1;
} else {
// shift bits right
buffer = buffer >> 1;
}
} else if( dir == 1 ) {
if( buffer == 61440 ) {
// switch direction
dir = 0;
} else {
// shift bits left
buffer = buffer << 1;
}
}
// Shift out the bits. To get the bit pattern for the leftmost
// register we shift the bits in the buffer to the right by 8 places.
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, buffer >> 8);
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, buffer);

// Set the latch pin high so that the pattern appears on
// the output pins of the shift registers
digitalWrite(LATCH_PIN, HIGH);
delay(50);
}
```

## Credits

### mariogianota

3 projects • 5 followers