Binary counter
Two 74HC74s divide a 4 Hz clock four times and count a four-bit number up a row of LEDs. There is no microcontroller in it: the simulator solves the 11 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
AdvancedRuns in your browser. Free, and no account needed.
How it works
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.
// A 4-bit ripple counter: eight flip-flops' worth of chip, four of them used.
//
// Each stage is a 74HC74 D flip-flop wired to toggle: D is tied to its own
// Q-bar, so whatever it is holding, the next rising clock edge loads the
// opposite. That divides the clock by two.
//
// clock 4 Hz -> Q0 2 Hz (bit 0, changes every 250 ms)
// Q0-bar -> Q1 1 Hz (bit 1)
// Q1-bar -> Q2 0.5 Hz (bit 2)
// Q2-bar -> Q3 0.25 Hz (bit 3)
//
// Read the four LEDs as a binary number and it steps 0001, 0010, 0011 ... 1111
// and round again, once every four seconds. Clocking each stage from Q-bar
// counts up; clocking it from Q instead counts down, and that one wire is the
// whole difference.
//
// Change the clock part's frequency in the properties panel to speed it up. At
// a few kHz you can no longer see the count, but the ripple is still there: the
// carry has to walk through every stage before the number is right, which is
// what limits how fast a counter like this can be read.
Parts list
13 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Full-size breadboard
- 1 × Power, 5 V
- 1 × Clock
- 2 × 74HC74 dual flip-flop
- 4 × Resistor, 220 Ω
- 1 × LED, red
- 1 × LED, yellow
- 1 × LED, green
- 1 × LED, blue
How it is wired
15 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- 5 V: 74HC74 dual flip-flop (1) pin 1RD; 74HC74 dual flip-flop (1) pin 1SD; 74HC74 dual flip-flop (1) pin 2SD; 74HC74 dual flip-flop (1) pin 2RD; 74HC74 dual flip-flop (1) pin VCC; 74HC74 dual flip-flop (2) pin 1RD; 74HC74 dual flip-flop (2) pin 1SD; 74HC74 dual flip-flop (2) pin 2SD; 74HC74 dual flip-flop (2) pin 2RD; 74HC74 dual flip-flop (2) pin VCC
- Ground: 74HC74 dual flip-flop (1) pin GND; 74HC74 dual flip-flop (2) pin GND; LED, red pin C; LED, yellow pin C; LED, green pin C; LED, blue pin C
- Clock pin OUT; 74HC74 dual flip-flop (1) pin 1CP
- 74HC74 dual flip-flop (1) pin 1D; 74HC74 dual flip-flop (1) pin 1QN; 74HC74 dual flip-flop (1) pin 2CP
- 74HC74 dual flip-flop (1) pin 1Q; Resistor, 220 Ω (1) pin 1
- 74HC74 dual flip-flop (1) pin 2QN; 74HC74 dual flip-flop (1) pin 2D; 74HC74 dual flip-flop (2) pin 1CP
- 74HC74 dual flip-flop (1) pin 2Q; Resistor, 220 Ω (2) pin 1
- 74HC74 dual flip-flop (2) pin 1D; 74HC74 dual flip-flop (2) pin 1QN; 74HC74 dual flip-flop (2) pin 2CP
- 74HC74 dual flip-flop (2) pin 1Q; Resistor, 220 Ω (3) pin 1
- 74HC74 dual flip-flop (2) pin 2QN; 74HC74 dual flip-flop (2) pin 2D
- 74HC74 dual flip-flop (2) pin 2Q; Resistor, 220 Ω (4) pin 1
- Resistor, 220 Ω (1) pin 2; LED, red pin A
- Resistor, 220 Ω (2) pin 2; LED, yellow pin A
- Resistor, 220 Ω (3) pin 2; LED, green pin A
- Resistor, 220 Ω (4) pin 2; LED, blue pin A
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.