Built-in project · no microcontroller

Decoder chaser

A 74HC14 oscillator clocks a 74HC161 counter and a 74HC138 decoder lights one LED of eight at a time. There is no microcontroller in it: the simulator solves the 21 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.

Teaching? Assign it to your class in one click.

Advanced About 45 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $7.65. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • A Schmitt trigger gate as an RC oscillator
  • A synchronous binary counter
  • A 3-to-8 decoder with active-low outputs
  • Lighting LEDs from an output that goes low
  • Tying unused control pins high or low
  • Difficulty: Advanced
  • Time: About 45 minutes
  • Parts: 23

How it works

Gate 6 of the 74HC14 is a clock. A 100k resistor feeds its output back to its input, and a 4.7 µF capacitor sits from its input to ground. The Schmitt input switches at two different voltages, so the capacitor charges and discharges between them and the output flips back and forth a little under 3 times a second.

That clock goes to the 74HC161 counter, which adds one on every rising edge. The counter's three low outputs, Q0, Q1 and Q2, go to the address pins A0, A1 and A2 of the 74HC138 decoder.

The decoder pulls exactly one of its eight outputs low, the one matching the address. Each LED runs from 5 V through 330 ohms into one output, so the LED on the low output lights. Q3 is unused, so the light runs along all eight LEDs twice for every sixteen counts.

Parts list

23 parts, plus the jumper wires. They retail for about $7.65; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
74HC14 Schmitt inverter pin VCC5 V
74HC161 4-bit counter pin MR5 V
74HC161 4-bit counter pin CEP5 V
74HC161 4-bit counter pin PE5 V
74HC161 4-bit counter pin CET5 V
74HC161 4-bit counter pin VCC5 V
74HC138 3-to-8 decoder pin E35 V
74HC138 3-to-8 decoder pin VCC5 V
Resistor, 330 Ω (1) pin 15 V
Resistor, 330 Ω (2) pin 15 V
Resistor, 330 Ω (3) pin 15 V
Resistor, 330 Ω (4) pin 15 V
Resistor, 330 Ω (5) pin 15 V
Resistor, 330 Ω (6) pin 15 V
Resistor, 330 Ω (7) pin 15 V
Resistor, 330 Ω (8) pin 15 V
74HC14 Schmitt inverter pin GNDGround
Capacitor, 4.7 µF pin 2Ground
74HC161 4-bit counter pin GNDGround
74HC138 3-to-8 decoder pin E1Ground
74HC138 3-to-8 decoder pin E2Ground
74HC138 3-to-8 decoder pin GNDGround
Resistor, 100k Ω pin 274HC14 Schmitt inverter pin 6Y
74HC161 4-bit counter pin CP74HC14 Schmitt inverter pin 6Y
Resistor, 100k Ω pin 174HC14 Schmitt inverter pin 6A
Capacitor, 4.7 µF pin 174HC14 Schmitt inverter pin 6A
74HC138 3-to-8 decoder pin A274HC161 4-bit counter pin Q2
74HC138 3-to-8 decoder pin A174HC161 4-bit counter pin Q1
74HC138 3-to-8 decoder pin A074HC161 4-bit counter pin Q0
LED, yellow (8) pin C74HC138 3-to-8 decoder pin Y7
LED, yellow (7) pin C74HC138 3-to-8 decoder pin Y6
LED, yellow (6) pin C74HC138 3-to-8 decoder pin Y5
LED, yellow (5) pin C74HC138 3-to-8 decoder pin Y4
LED, yellow (4) pin C74HC138 3-to-8 decoder pin Y3
LED, yellow (3) pin C74HC138 3-to-8 decoder pin Y2
LED, yellow (2) pin C74HC138 3-to-8 decoder pin Y1
LED, yellow (1) pin C74HC138 3-to-8 decoder pin Y0
LED, yellow (1) pin AResistor, 330 Ω (1) pin 2
LED, yellow (2) pin AResistor, 330 Ω (2) pin 2
LED, yellow (3) pin AResistor, 330 Ω (3) pin 2
LED, yellow (4) pin AResistor, 330 Ω (4) pin 2
LED, yellow (5) pin AResistor, 330 Ω (5) pin 2
LED, yellow (6) pin AResistor, 330 Ω (6) pin 2
LED, yellow (7) pin AResistor, 330 Ω (7) pin 2
LED, yellow (8) pin AResistor, 330 Ω (8) pin 2

The notes that come with it

There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.

sketch.ino
// Count, then decode: a 74HC161 and a 74HC138 light one LED of eight.
//
// 1. The clock. Gate 6 of the 74HC14 has a 100k resistor from its output back
//    to its input and a 4.7 uF capacitor from its input to ground. A Schmitt
//    input switches at two different voltages (about 2.8 V going up, 1.8 V
//    going down), so the capacitor chases the output up and down between them
//    and it oscillates: about 0.8 x R x C, a little under 3 Hz.
//
// 2. The count. The 74HC161 adds one on every rising edge of CP. All four
//    outputs change on the same edge: a synchronous counter.
//
// 3. The decode. Q0, Q1 and Q2 go to the 138's address pins A0, A1, A2, and
//    the 138 pulls exactly one of Y0..Y7 low: Y3 when the address is 3. Each
//    LED runs from 5 V through 330 ohms into one output, so the low one lights.
//
// Q3 is not used, so the light runs along the eight LEDs twice for every
// sixteen counts. Change C1 in the properties panel to change the speed.

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • No LED ever lights. This project
    The decoder needs E1 and E2 to ground and E3 to 5 V to be enabled.
  • The light never moves. This project
    On the counter, MR, PE, CEP and CET must all be tied to 5 V, and the clock must reach the CP pin.
  • The chase is too fast or slow. This project
    Change the capacitor C1 in the properties panel. A bigger value is slower.
  • An unused gate input floats, so the output flickers and the chip draws extra current. 74HC14 Schmitt inverter
    Tie unused inputs to GND or VCC. A floating CMOS input drifts and can oscillate. Add a 100 nF capacitor between VCC and GND close to the chip.
  • The R and C oscillator does not run or runs at the wrong frequency. 74HC14 Schmitt inverter
    Feed the output back through R to the input and put C from the input to ground. Frequency is roughly 1 divided by (R times C) with a spread, so use a scope. Keep R above about 1 k.
  • The LED is dim, burns out, or the pin reads wrong because the resistor value is off. Resistor
    Read the color bands again. A 220 ohm to 330 ohm resistor suits a typical LED on 5 V. 10k is a common pull-up or pull-down value. Check with a multimeter if unsure.
  • A pull-up or pull-down resistor is missing, so the input floats and reads random values. Resistor
    Tie the input to 5 V or ground through about 10k. Or use INPUT_PULLUP and wire the switch to ground.
  • An electrolytic capacitor heats up, bulges or pops. Capacitor
    Electrolytics have a polarity. The stripe marks the negative leg, which goes toward ground. Also keep the voltage under the rated value, such as 10 V or 16 V.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.