D Flip-Flop 4-Bit Counter
Build a 4-bit binary counter using two 74LS74 D flip-flop ICs—watch it count from 0 to 15 in binary using LEDs!
Overview
A binary counter is one of the most important sequential circuits. By connecting D flip-flops in a toggle configuration (wiring Q̄ back to D), each flip-flop divides the clock frequency by 2. Cascading four such flip-flops creates a 4-bit ripple counter that counts from 0000 to 1111 (0 to 15) and wraps back to 0. This project uses two 74LS74 ICs (each containing two D flip-flops) to build the complete counter with 4 LED outputs.
Components Needed
- 2x SN74LS74 IC (Dual D Flip-Flop)
- 1x Switch
- 4x LED
- severalx Wires
Instructions
Gather Your Components
Collect two SN74LS74 dual D flip-flop ICs (giving you 4 flip-flops total), one switch (for the clock input), four LEDs (one per bit), wires, breadboard, and 5V power supply.
Identify the SN74LS74 IC
Each 74LS74 contains two independent D flip-flops. Pin 14 is VCC, Pin 7 is GND. For flip-flop 1: Pin 2 is D, Pin 3 is CLK, Pin 5 is Q, Pin 6 is Q̄. Pins 1 and 4 are Clear and Preset (tie to VCC to disable). For flip-flop 2: Pin 12 is D, Pin 11 is CLK, Pin 9 is Q, Pin 8 is Q̄.
Wire the 4-Bit Counter
Place both ICs on the breadboard and connect power. For each flip-flop, connect Q̄ back to D (toggle configuration). Connect the switch to the clock of the first flip-flop. Chain the Q output of each flip-flop to the clock of the next. Connect the four Q outputs to LEDs. Tie all Clear and Preset pins to VCC.
Count 0: 0000
Starting state after power-on (you may need to manually reset). All four LEDs are OFF, showing binary 0000 (decimal 0).
Count 1: 0001
Toggle the clock switch once. The first flip-flop toggles to 1. LEDs show 0001 (decimal 1).
Count 2: 0010
Another clock toggle. Bit 0 goes back to 0, and the transition clocks bit 1 to toggle ON. LEDs show 0010 (decimal 2).
Count 3: 0011
Clock again. Bit 0 toggles to 1. LEDs show 0011 (decimal 3).
Count 4: 0100
Clock again. Bits 0 and 1 toggle back to 0, and the carry ripples to toggle bit 2 ON. LEDs show 0100 (decimal 4).
Count 5: 0101
LEDs show 0101 (decimal 5).
Count 6: 0110
LEDs show 0110 (decimal 6).
Count 7: 0111
LEDs show 0111 (decimal 7). All lower 3 bits are on—the next count will carry into bit 3!
Count 8: 1000
A big transition! The carry ripples through all four bits. Bits 0-2 go to 0, and bit 3 toggles ON. LEDs show 1000 (decimal 8).
Count 9: 1001
LEDs show 1001 (decimal 9).
Count 10: 1010
LEDs show 1010 (decimal 10).
Count 11: 1011
LEDs show 1011 (decimal 11).
Count 12: 1100
LEDs show 1100 (decimal 12).
Count 13: 1101
LEDs show 1101 (decimal 13).
Count 14: 1110
LEDs show 1110 (decimal 14).
Count 15: 1111
All four LEDs ON! LEDs show 1111 (decimal 15)—the maximum value for a 4-bit counter. The next clock pulse will wrap back to 0.
Rollover: Back to 0000
One more clock pulse and the counter wraps around to 0000. All LEDs turn OFF. The counter has completed a full cycle through all 16 states (0-15) and is ready to count again!
Challenges
- Add a reset button by connecting it to all Clear pins
- Replace the manual switch with a 555 timer for automatic counting
- Connect a BCD 7-segment display to see decimal values
- Cascade with two more flip-flops for an 8-bit counter (0-255)
- Build a count-down counter by using Q̄ outputs instead of Q