Build the Iconic Knight Rider Scanner: Master the CD4017 Decade Counter

Build the Iconic Knight Rider Scanner: Master the CD4017 Decade Counter


📑Table of Contents
What You'll Need 5 items
CD4017 Decade Counter
Buy
555 Timer IC
Buy
Breadboard
Buy
10×
5mm LED
Buy
Jumper Wires
Buy

Affiliate links help support this site at no extra cost to you.

Welcome to Day 10. We have reached a milestone. For the past 9 days, we have built the fundamentals.

  • Resistance (Day 2)
  • Switching (Day 4)
  • Timing (Day 5)
  • Sensing (Day 6)
  • Counting (Day 9)

Today, we combine them all. We are going to build Art. We are going to build the most famous circuit in television history. The red, scanning eye of K.I.T.T. from Knight Rider. (Or the Cylon eye check from Battlestar Galactica, if you prefer).

This project, known as an LED Chaser, is the “Hello World” of intermediate electronics. If you can build this, you are no longer a beginner.

Knight Rider Scanner Closeup

The Star of the Show: The CD4017

Yesterday, we used the 74HC93 Binary Counter. It counted in binary: 0000, 0001, 0010… That is great for computers, but terrible for humans. If you hook up LEDs to a binary counter, they look like a chaotic disco. They don’t “chase”.

To make LEDs turn on one at a time (1, then 2, then 3…), we need a different kind of counter. We need a Decade Counter. Enter the CD4017.

How it counts

The CD4017 has 10 Output Pins (Q0 to Q9). Unlike the binary counter, the CD4017 uses “One-Hot” encoding. Only ONE output is High at a time. All others are Low.

Deep Dive: The Johnson Counter Architecture

Technically, the CD4017 is a Johnson Counter (Twisted Ring Counter). Inside, it uses 5 D-Flip Flops in a chain. The output of the last Flip-Flop is inverted and fed back to the first. This creates a pattern of 00000 -> 10000 -> 11000… Then a complex logic decoder translates these weird states into the “One-Hot” outputs (Pin 3, Pin 2, etc.) that you see. This is why the pinout is so scrambled. The engineers prioritized the silicon layout over your convenience!

  • Pulse 1: Q0 is ON.
  • Pulse 2: Q1 is ON.
  • Pulse 3: Q2 is ON.
  • Pulse 10: Q9 is ON.
  • Pulse 11: Back to Q0.

It is like a spotlight moving down a line of dancers.

Binary vs Decade Counter Comparison

CMOS vs TTL (A Quick Warning)

Notice the name starts with CD (4000 series), not 74 (7400 series).

  • 74xx (TTL): Built with Bipolar Transistors. Fast. Power hungry. Needs exactly 5V.
  • 40xx (CMOS): Built with MOSFETs. Slow. Ultra-low power. Works from 3V to 15V.

Because it is CMOS, it is extremely sensitive to static electricity. The 74HC93 from yesterday was tough. The CD4017 is fragile. Do not touch the pins after walking on carpet. Touch a metal table leg first!

The Pinout (The Map)

This chip is a DIP-16. It has 16 legs. The pin layout is… chaotic. The outputs are NOT in order. Q0 is Pin 3. Q1 is Pin 2. Q2 is Pin 4. Why? Because the silicon layout inside was easier that way. You Must follow the diagram. Do not guess.

CD4017 Pinout Diagram

  • 14 (CLK): The Clock Input (Where we send pulses).
  • 16 (VCC): Power (+3V to +15V).
  • 8 (GND): Ground (0V).
  • 15 (Reset): If High, resets count to Q0. Usually grounded.
  • 13 (Clock Inhibit): If High, ignores the clock. Must be grounded to count.
  • Outputs (Q0-Q9): The random pins.

Project 1: The Simple LED Chaser

Before we build K.I.T.T., let’s just make a simple 10-LED chaser. It will run from LED 1 to LED 10 and repeat.

The Engine: The 555 Timer

The CD4017 is just the legs. It needs a heart to beat. We will use our trusty 555 Timer (from Day 5) in Astable Mode to generate the pulses. The 555 output (Pin 3) connects to the CD4017 Input (Pin 14).

The Schematic

It looks like a spaghetti monster, but break it down. Left Side: Standard 555 Astable Circuit. Right Side: CD4017 with 10 LEDs.

Simple Chaser Schematic

Step-by-Step

  1. Build the 555 Circuit:
    • Pin 1 to GND, Pin 8 to VCC.
    • Pin 4 to VCC (Reset).
    • Bridge Pin 2 and 6.
    • Capacitor (10uF) from Pin 2 to GND.
    • Potentiometer between Pin 7 and Pin 6.
    • Resistor (1k) between Pin 7 and VCC.
  2. Verify: Putting an LED on Pin 3 of the 555. Does it blink? Good. Remove the LED.
  3. Place the CD4017:
    • Pin 16 to VCC, Pin 8 to GND.
    • Crucial: Connect Pin 13 (Enable) and Pin 15 (Reset) to GND. If you forget this, it does nothing.
  4. Connect the Heart: Wire 555 Pin 3 to CD4017 Pin 14.
  5. Wire the LEDs:
    • This is the tedious part.
    • Pin 3 -> LED 1
    • Pin 2 -> LED 2
    • Pin 4 -> LED 3
    • … (Follow the datasheet).
    • Use a single 330Ω resistor on the Ground side of all LEDs (Shared cathode) to save parts. Since only one is on at a time, they can share one resistor!

Breadboard Render of Chaser

Turn it on. The LEDs should march one by one. Turn the potentiometer on the 555 to make them run faster or slower.

Project 2: The Knight Rider (The Larson Scanner)

The simple chaser is cool, but it loops. 1-2-3-4-5-6-7-8-9-10 -> 1-2… K.I.T.T. didn’t loop. K.I.T.T. scanned Back and Forth. 1-2-3-4-5-6… 5-4-3-2-1.

How do we do that? Do we need a chip that counts backwards? (Those exist, like the CD4029, but they are expensive). We can cheat.

We don’t need the chip to count backwards. We just need to arrange the LEDs so it looks like it’s counting backwards. It’s a magic trick.

The Trick

We use the 10 outputs to drive 6 LEDs. We double-wire the middle LEDs.

  • Count 0: LED A (Left)
  • Count 1: LED B
  • Count 2: LED C
  • Count 3: LED D
  • Count 4: LED E
  • Count 5: LED F (Right)
  • Count 6: LED E (Back to E!)
  • Count 7: LED D
  • Count 8: LED C
  • Count 9: LED B
  • (Reset to 0 -> LED A)

See? The counter is going forward (0 to 9), but the light bounces off the walls. We need Diodes (1N4148 or similar) on the double-wired connections to prevent the electricity from flowing backwards into the wrong pin.

Knight Rider Schematic

Wiring the Hack

  1. Keep your 555 and 4017 setup.
  2. Remove the 10 LEDs.
  3. Place 6 LEDs in a row.
  4. Connect Q0 to LED 1.
  5. Connect Q1 to LED 2.
  6. Connect Q2 to LED 3.
  7. Connect Q5 to LED 6.
  8. Now the return trip:
    • Connect Q6 to LED 5.
    • Connect Q7 to LED 4.
    • Connect Q8 to LED 3.
    • Connect Q9 to LED 2.

Note: If you get “Ghosting” (weird LEDs lighting up), add 1N4148 diodes on the output pins. Or, for a simpler version without diodes: Just accept that two pins are fighting. The CD4017 is weak enough that it usually survives, but it’s bad practice. Better method: Just stick to 10 LEDs in a circle to simulate a “Cylon Eye” loop if you don’t have diodes.

Waveform Diagram of Scanning

The Hack: Resetting Early

What if you only have 4 LEDs? You don’t want to wait for the counter to count to 10 (with 6 seconds of darkness) before it restarts. You want it to count 1-2-3-4 -> Reset.

The Solution: Connect the N+1 output to the Reset (Pin 15). If you want to count to 4 (Q0, Q1, Q2, Q3): Connect Q4 (Pin 10) to Reset (Pin 15). As soon as the chip tries to turn on Q4, it instantly touches the Reset button and jumps back to Q0. It happens so fast (nanoseconds) that Q4 never even lights up.

Trivia: The Larson Scanner

Why is it called that? It is named after Glen A. Larson, the television producer who created both Knight Rider (1982) and Battlestar Galactica (1978). He loved the scanning red eye effect.

  • In Battlestar Galactica, it was the eye of the Cylon Centurions.
  • In Knight Rider, it was the nose of K.I.T.T. Technically, he didn’t solder the circuit, but his vision made it famous. Before him, LEDs were just boring status indicators. After him, LEDs were cool.

Reset Logic Diagram

Reset Logic Diagram

Deep Dive: The Logic of the Scanner

Why is this circuit so satisfying? It represents persistence. It is a machine that is constantly searching. When you look at the waveform, it is a waterfall. When you look at the LEDs, it is a pendulum. It is the bridge between the digital world (discrete steps) and the physical world (motion).

Troubleshooting The Scanner

  1. It stops at random? Pin 13 (Clock Inhibit) is floating. Ground it!
  2. It resets randomly? Pin 15 (Reset) is floating. Ground it!
  3. It skips LEDs? Your clock is too “noisy” (Switch Bounce). If using a button instead of a 555, you need a capacitor.
  4. Dim LEDs? The CD4017 is weak. It can only output about 10mA. If you need blinding brightness, you need Transistors (Day 4) to amplify each output.

Engineering Challenge: Driving High Loads

What if you want to scan 110V Light Bulbs? Or Horns? The CD4017 cannot do this. It will explode. You need Buffers. Connect each Output Pin to the Base of an NPN Transistor (2N2222). The Transistor then drives the heavy load (Relay or High-Power LED). This is how big Las Vegas signs work. A tiny brain chip controlling massive power transistors. Rule: Logic chips make decisions. Transistors move muscles.

Wall of LEDs Art

The Bill of Materials (BOM)

ComponentQuantityValueNotes
CD40171Decade CounterThe Brain
NE5551TimerThe Heart
LEDs10Red (Diffused)Classic look
Resistor1330ΩFor LEDs
Resistor11kΩFor 555
Potentiometer1100kΩSpeed Control
Capacitor110uFTiming
Diodes81N4148Optional (for Scanner)

Advanced Academy: Cascading Counters

What if 10 LEDs aren’t enough? What if you want to count to 100? You can Cascade these chips, just like we did with the Binary Counters. But it’s tricky. Ideally, when Chip A finishes (Pulse 10), it should trigger Chip B to move one step. The Secret Pin: Pin 12 (Carry Out).

  • Pin 12 stays HIGH for counts 0-4.
  • Pin 12 stays LOW for counts 5-9.
  • When it goes from Low to High (count 9 -> 0), it creates a “Rising Edge”. You can connect Pin 12 of Chip A to Pin 14 (Clock) of Chip B. Result: Chip A counts 0-9. Chip B counts 1. Chip A counts 0-9. Chip B counts 2. This is exactly how an odometer works.

CMOS Safety: The Silent Killer

We mentioned static electricity, but there is another killer. Floating Inputs. In TTL chips (74xx), an unconnected input usually defaults to High. In CMOS chips (40xx), an unconnected input is… undefined. It becomes a radio antenna. It picks up 60Hz hum from your wall wiring. If you leave an input pin floating, your chip might oscillate at 1,000,000 times a second, get super hot, and die. Rule: ALWAYS connect unused inputs to VCC or GND. Never leave them floating.

Real World Applications: Where is the 4017?

This chip isn’t just a toy.

  1. Traffic Lights: Old school controllers used 4017s to cycle Red -> Yellow -> Green.
  2. Music Sequencers: 8-step synthesizers (like the Baby 8) use a 4017 to trigger 8 different pitch potentiometers in a row.
  3. Vending Machines: To count loops of a motor.
  4. Wait, is it in my phone? No. Modern tech uses Microcontrollers (which we start tomorrow). But the concept of the decade counter lives on in software loops.

Part 1 Review: The Quiz

You have finished the “Hardware” phase. Can you answer these before moving to “Software” tomorrow?

  1. V = I * R. What is this law called? (Day 2)
  2. NPN vs PNP. Which one switches to Ground? (Day 4)
  3. Astable vs Monostable. Which one pulses forever? (Day 5)
  4. Voltage Divider. Why do LDRs need a fixed resistor? (Day 6)
  5. Flip-Flop. What makes it remember? (Day 8)

If you hesitated, look back. Tomorrow, we write code.

The Engineer’s Glossary (Day 10)

  • Decade Counter: A counter with 10 unique outputs.
  • One-Hot: A coding scheme where only one bit is High at a time.
  • CMOS: Complementary Metal-Oxide Semiconductor. Low power, high static sensitivity.
  • Cascading: Connecting multiple chips to count higher (10, 20, 30…).
  • Clock Inhibit: A “Pause” button on the chip.

Conclusion: The First 10 Days

You made it. Ten days ago, you didn’t know what a voltage divider was. Today, you built a self-clocking, sequential logic scanning array. That is massive progress.

You have now completed Part 1: The Fundamentals.

  • Part 1 (Days 1-10): Components & Basic Logic.
  • Part 2 (Days 11-20): Microcontrollers (Arduino).

Tomorrow, we change the game. We stop wiring logical chips manually. We start Coding. We are going to introduce the Arduino Uno. We will replace that mess of wires on your breadboard with a few lines of C++ code. Get your USB cables ready. The software era begins.

See you on Day 11.

Part 1 Retrospective: From Zero to Hero

Let’s pause and look at your breadboard. Ten days ago, it was empty. Now, you likely have a collection of resistors, capacitors, chips, and wires that looks like a rat’s nest. This is good. This is learning. Here is what you have mastered:

  1. Thinking in Voltage: You stopped seeing wires as just connectors and started seeing them as pipes carrying pressure.
  2. The Divider: You learned how to split that pressure using resistors.
  3. The Switch: You learned that transistors are just electronic buttons.
  4. The Clock: You learned that time is just a capacitor filling up and emptying out.
  5. The Logic: You learned that complex decisions (AND, OR, NOT) can be built from simple gates.
  6. The Memory: You trapped a ghost in a machine (Flip-Flop).
  7. The Sequence: You laid out a path for electrons to follow (Counter).

You effectively built a 1970s computer from scratch.

Preparing for Part 2: The Software Revolution

For the next 10 days, we are going to change the rules. We are moving to the Arduino. To prepare, you might need to order some new parts if you don’t have them:

  1. Arduino Uno (or Clone): The brain.
  2. USB Cable: To talk to it.
  3. Servo Motor: To make things move.
  4. LCD Screen (16x2): To make things speak.
  5. Ultrasonic Sensor (HC-SR04): To see distance.

Why change? Building that Knight Rider circuit took 2 chips, a capacitor, a pot, and 20 wires. With an Arduino, it takes Zero chips and 10 wires. We replace the hardware complexity with software complexity. It is cleaner. It is faster. But it is different. You need to learn to type code.

A Final Challenge

Before you tear down your 4017 circuit… Try to make it “Bounce” without the extra LEDs. Can you use the outputs to trigger a second 555 timer that changes the speed? Can you make it speed up and slow down like a heartbeat? The chip has no brain, but you do. Be creative.

End of Part 1.

Comments