part · Level 6 · Logic · active
What a CD4017 decade counter does
CD4017 decade counter — Counts clock pulses from 0 to 9 and lights one of ten outputs for each count. The chip behind every LED chaser.
What it is
A counter is a chip that remembers how many times something has happened. The CD4017 is a decade counter: it counts from 0 to 9, then wraps back to 0. Each count has its own output pin, Q0 to Q9, and exactly one of them is high at any moment, the one matching the count. Everything else sits low.
What it counts are rising edges on its CLOCK pin: each time that input goes from low to high, the count goes up by one and the high output moves to the next pin. Feed it a steady tick from a 555 and the high output walks along all ten pins, which is why it is the chip behind almost every LED chaser and sequencer.
Like the CD4011, it is a 4000-series CMOS chip: it runs on 3 to 18 V, so a 4.5 V pack is fine, its inputs draw almost no current, and its outputs are weak, enough to light an LED dimly.
How it works
Pins, anticlockwise from the notch: 1 Q5, 2 Q1, 3 Q0, 4 Q2, 5 Q6, 6 Q7, 7 Q3, 8 VSS (−), 9 Q8, 10 Q4, 11 Q9, 12 CARRY OUT, 13 CLOCK INHIBIT, 14 CLOCK, 15 RESET, 16 VDD (+). The outputs really are scrambled like that; it is the same on every 4017.
The control inputs. Three pins decide what the counter does:
- CLOCK (14): every low-to-high edge adds one to the count.
- RESET (15): high forces the count to 0, at once, whatever the clock is doing. Low lets it count.
- CLOCK INHIBIT (13): high makes the counter ignore the clock and hold its count. Low lets it count.
Tie RESET and INHIBIT low (straight to −, or through a pull-down) and the chip just counts.
Counting to fewer than ten. Connect an output back to RESET. With Q4 jumpered to RESET, the count runs 0, 1, 2, 3, and the instant it reaches 4, Q4 goes high and resets it to 0. Q4 is high for a fraction of a microsecond, too short to see, so the counter now counts to four. Use Q6 for six steps, Q3 for three.
CARRY OUT (12) is high for counts 0 to 4 and low for 5 to 9: one full cycle for every ten clock pulses. Feed it to a second 4017's clock and the second chip counts tens.
Timing a chaser. The step time is the clock's period. A 555 with R1 = R2 = 10 kΩ and C = 10 µF is high for 0.693 × 20 000 × 0.000 01 ≈ 0.139 s and low for 0.693 × 10 000 × 0.000 01 ≈ 0.069 s, a period of 0.208 s, so each LED is lit for about a fifth of a second and four LEDs make a lap in 0.83 s.
What an output can drive. About 1 mA at 5 V, per the datasheet. The Workbench models each output as about 200 Ω to the rail it is driving, so a red LED through 220 Ω on 4.5 V shows (4.5 − 2.0) ÷ (200 + 220) ≈ 6 mA. Because only one output is ever high, the LEDs of a chaser can share a single resistor between their short legs and −.
The numbers
| Counts | 0 to 9, one output high per count |
|---|---|
| Supply | 3–18 V — pin 16 VDD, pin 8 VSS |
| Counts on | rising edge of CLOCK (pin 14) — while INHIBIT (pin 13) and RESET (pin 15) are low |
| Q0 … Q4 pins | 3, 2, 4, 7, 10 |
| Q5 … Q9 pins | 1, 5, 6, 9, 11 |
| CARRY OUT | high for counts 0–4 — pin 12; clocks the next counter |
| Output drive | ≈ 1 mA at 5 V — datasheet; sims model ≈ 200 Ω to the rail |
| Red LED on an output via 220 Ω | ≈ 6 mA (sim) — a real chip lights it dimmer |
See it working
The The Four-Step Chaser circuit, simulated live. Open it on the Workbench to change anything.
simulating…
Mistakes everyone makes
- RESET or INHIBIT left floating. A floating CMOS input drifts, and the count freezes, jumps or resets at random. Fix: tie both to − (or to an output, for RESET), or give them a 100 kΩ pull-down.
- Expecting the outputs in order. Q0 is pin 3, not pin 1. Fix: use the pin list above, not the chip's physical order.
- A clock that bounces. A push-button on CLOCK makes several edges per press as its contacts bounce, so the count jumps by two or three. Fix: clock it from a 555, or debounce the button.
- Chip in backwards. Pin 1 is next to the notch; powering it backwards can kill it within seconds. Fix: check the notch before the battery.
- Static. CMOS inputs are easily damaged by a spark. Fix: touch something earthed first, store the chip in conductive foam.
Questions people ask
- What does a 4017 decade counter do?
- It counts rising edges on its clock pin from 0 to 9 and makes one of its ten outputs high for each count, so a steady clock makes a single high output walk along all ten pins.
- How do I make a 4017 count to less than 10?
- Connect the output one past your last step to RESET (pin 15). Q4 to RESET counts 0 to 3; Q6 to RESET counts 0 to 5.
- Do the LEDs on a 4017 each need a resistor?
- Only one output is high at a time, so in a simple chaser the LEDs can share one resistor between their short legs and −. If two outputs can ever be high together, give each LED its own.
Projects that use this part
- 🏃 The Four-Step Chaser — A 555 ticks five times a second and a CD4017 counter walks the light from LED to LED, round and round. Hold a button and the chase freezes. L6 · 60 min
verified against: Texas Instruments — CD4017B decade counter/divider datasheet · SparkFun — Digital Logic