Teaching Sand to Count: Master Binary & Build a 4-Bit Counter Circuit

Teaching Sand to Count: Master Binary & Build a 4-Bit Counter Circuit


📑Table of Contents
What You'll Need 5 items
SN74HC93N (4-bit Counter)
Buy
555 Timer IC
Buy
Breadboard
Buy
5mm LED
Buy
Jumper Wires
Buy

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

Welcome to Day 9 of our Electronics for Absolute Beginners series.

Yesterday (Day 8), we taught a rock to Remember. We built a single bit of memory. A cell that could hold a 0 or a 1. It was like teaching a child a single word. “Yes” or “No”.

Today, we teach the rock to Count. We are going to chain those memory cells together to create a machine that understands the passage of time. A machine that can count: 0, 1, 2, 3, 4…

This is the birth of Mathematics in silicon. This is how your watch knows seconds. This is how your car knows miles. This is how your computer knows memory addresses.

Binary Counting Introduction Art

The Alien Math: Thinking in Binary

Before we touch a chip, we must understand the language of the machine. Humans count in Decimal (Base 10). Why? Because we have 10 fingers. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9… what comes next? We run out of unique symbols. So we add a “1” to the left column and reset the right column to “0”. 10.

Computers don’t have fingers. They have switches (Transistors). A switch has only two states: OFF (0) or ON (1). So they count in Binary (Base 2).

The Power of Two

In Decimal, every column is worth 10 times more than the last (1s, 10s, 100s, 1000s). In Binary, every column is worth 2 times more than the last.

  • 1st Bit: Worth 1
  • 2nd Bit: Worth 2
  • 3rd Bit: Worth 4
  • 4th Bit: Worth 8
  • 5th Bit: Worth 16

Binary vs Decimal Visual Chart

Let’s Count to 15

Let’s look at 4 bits (a “Nibble”).

Decimal8s Column4s Column2s Column1s ColumnBinary
000000000
100010001
200100010
300110011
401000100
1511111111

Notice the pattern? The 1s column flips every time (0,1,0,1). The 2s column flips every two times (0,0,1,1). The 4s column flips every four times. The 8s column flips every eight times.

This is the key. To build a counter, we just need a circuit that flips half as fast as the one before it.

Philosophy: Why Start at Zero?

Humans count: 1, 2, 3. Computers count: 0, 1, 2. Why? Because Zero is a value. If you have 4 bits, you have 16 combinations (242^4). If you started at 1, you would count 1 to 16. But “0000” (all switches off) is a valid state physically. If we ignored it, we would waste a state. So we count 0 to 15. This is called Zero-Indexing. It’s why array Item[0] exists in programming. It’s not to annoy you; it’s physics.

The Mechanics: The Ripple Effect

Recall the Flip-Flop from yesterday. It changes state (“toggles”) when the Clock signal hits it. What if… we take the Output (Q) of Flip-Flop A, and plug it into the Clock Input (CLK) of Flip-Flop B?

  1. Flip-Flop A is clocked by your button. It toggles 0->1->0->1.
  2. Flip-Flop B only cares when A goes “High”. So it only toggles when A finishes a full cycle. It runs at half the speed.
  3. Flip-Flop C runs at half the speed of B (1/4 speed).
  4. Flip-Flop D runs at half the speed of C (1/8 speed).

We have physically built the binary table above. This chain is called a Ripple Counter. Why “Ripple”? Because the change ripples through the chain like dominoes. A triggers B, B triggers C, C triggers D.

Ripple Counter Diagram

The Hardware: The 74HC93

We could build this with two 74HC74 chips (since each has 2 flip-flops). But that’s messy wiring. Instead, we use a dedicated Counter chip: The 74HC93 (or 74LS93).

It contains four flip-flops pre-wired for us. Well, almost.

Inside the Chip

The 74HC93 is slightly weird. It is split into two parts:

  1. Input A -> Bit 0: A single, lonely flip-flop.
  2. Input B -> Bit 1, 2, 3: A chain of three flip-flops.

Why is it split? Versatility. Sometimes you only need a divide-by-8 counter. To make a 4-bit (0-15) counter, we must manually connect the output of the first one to the input of the chain. WE MUST CONNECT Pin 12 (Q0) to Pin 1 (Input B). This bridges the gap and creates a single 4-bit chain.

74HC93 Pinout Render

Pinout Breakdown:

  • Input A (Pin 14): The main Clock input (from our button).
  • Input B (Pin 1): The input for the 2nd stage.
  • Outputs: Q0 (Pin 12), Q1 (Pin 9), Q2 (Pin 8), Q3 (Pin 11).
  • Resets (R0(1), R0(2)): Pins 2 and 3. When BOTH are High, count resets to 0.

Project: The 4-Bit Binary Counter

We are going to build a machine with 4 LEDs. We will press a button, and the LEDs will count up in binary. 0001 0010 0011…

Components Needed

  • 1x 74HC93 (or 74LS93) IC
  • 1x Push Button (Tactile)
  • 4x LEDs (Red, Green, Blue, Yellow - helps distinguish bits)
  • 4x 330Ω Resistors (for LEDs)
  • 1x 10kΩ Resistor (Pull-down for button)
  • Jumper Wires & Breadboard
  • Power Source (5V)

The Schematic

Pay attention to the “External Bridge” wire.

Project Schematic Diagram

Critical Wiring Details:

  1. Power: Pin 5 is VCC (+5V). Pin 10 is GND. (Note: This is non-standard! Usually it’s 14/7. Check your datasheet! The 7493 is weird).
  2. The Bridge: Connect Pin 12 to Pin 1. This chains the counters.
  3. The Input: Button goes to Pin 14 (Input A). Use a Pull-Down resistor!
  4. The Resets: Connect Pin 2 and Pin 3 to GND. (We want to count, not reset).
  5. The Outputs:
    • Pin 12 -> LED 1 (1s)
    • Pin 9 -> LED 2 (2s)
    • Pin 8 -> LED 3 (4s)
    • Pin 11 -> LED 4 (8s)

Step-by-Step

  1. Place the Chip. Bridge the gap.
  2. Power it. Be careful with Pin 5/10. It’s easy to get wrong if you are used to the 7400/7474.
  3. Ground the Resets. Pins 2 & 3 to Blue Rail.
  4. Install the Bridge. Wire Pin 12 to Pin 1.
  5. Wire the Input. Button to Pin 14. 10k resistor to Ground.
  6. Wire the LEDs. Remember counting order! Put the “1s” LED on the right, “8s” on the left, so it reads like a number.

Breadboard Render

Testing the Machine

  1. Power up. LEDs should be off (or random).
  2. Press the button.
  3. LED 1 (1) turns ON. (Binary 0001)
  4. Press again.
  5. LED 1 OFF, LED 2 (2) ON. (Binary 0010)
  6. Press again.
  7. LED 1 + LED 2 ON. (Binary 0011 = 3)
  8. Press again.
  9. LEDs 1&2 OFF, LED 3 (4) ON. (Binary 0100)

Keeps going until 15 (1111), then resets to 0000.

Note: If it skips numbers, you have Switch Bounce! (See Day 8). Ideally, use a 555 Timer (Day 5) as the clock source for a smooth, automatic count.

Deep Dive: Timing Diagrams (The Wave)

Engineers visualize counters using Timing Diagrams. It looks like a staircase of waves.

  • Clock: Fast pulses. ||||||||
  • Q0: Half speed. | | | |
  • Q1: Quarter speed. | | |
  • Q2: Eighth speed. | |

Timing Diagram Waveform

This is formally called Frequency Division. If you put a 1000Hz signal into Input A:

  • Q0 outputs 500Hz.
  • Q1 outputs 250Hz.
  • Q2 outputs 125Hz.
  • Q3 outputs 62.5Hz.

This is exactly how a digital watch works. It starts with a quartz crystal vibrating at 32,768Hz. It divides by 2… fifteen times. 32768/215=132768 / 2^{15} = 1. The result is 1 Hz. One pulse per second. Your watch is just a 15-bit Ripple Counter.

Real World limitation: Propagation Delay

Why don’t we use Ripple Counters in Supercomputers? Speed. Remember the dominoes? Domino A has to fall before it hits B. B has to fall before C. Each chip takes a tiny amount of time to react (nanoseconds). This is called Propagation Delay.

If you have a 64-bit counter: By the time the signal ripples from Bit 0 to Bit 63, the input clock might have already changed again! The number becomes corrupt for a split second. This “glitch” is unacceptable for high-speed processors. Solution: Humans invented Synchronous Counters (like the 74HC163). In these chips, all output bits change at the exact same instant. The Clock is wired to every flip-flop directly. It is harder to build, but much faster. For our LEDs? The Ripple Counter is fine. We can’t see nanoseconds.

Troubleshooting

  • LEDs light up randomly? Check Pins 2 & 3. If they are floating (not connected to Ground), static electricity will trigger the Reset.
  • Count is weird/skipping? Just wire bounce. Try adding a 0.1uF capacitor across the button legs, or trigger it with your 555 timer circuit from Day 5.
  • Chip getting hot? Did you assume VCC was Pin 14? Check Pin 5!

The Safety Checklist (Don’t Fry Your Chip)

The 74HC93 is infamous for destroying beginners’ confidence. Why? Because it breaks the rules.

  1. Pin 5 is VCC: On almost every other chip, VCC is Pin 14. If you plug +5V into Pin 14 on a 74HC93, you are powering the Input, not the chip. It won’t work.
  2. Pin 10 is GND: On other chips, GND is Pin 7. If you ground Pin 7, you are grounding… nothing. (Pin 7 is unconnected).
  3. Floating Resets: Pins 2 and 3 are the “Master Reset”. If you leave them unconnected (Floating), they act like antennas. Your counter will get to “3” and then randomly reset to “0” because the wire picked up a radio station. ALWAYS tie them to Ground.

Philosophy: Why is Binary so hard?

If you feel confused, don’t worry. You are fighting 200,000 years of evolution. Our brains are wired for:

  1. Analog magnitudes: “That lion is bigger than me.”
  2. Base 10: “I have five fingers.” Thinking in Base 2 requires you to discard your intuition. In Binary:
  • 1 + 1 = 10.
  • 10 is not “Ten”, it is “One-Zero” (which is Two). It takes practice. But once you see the pattern, you see the matrix.

Internal X-Ray: What’s inside?

If you popped the lid off the 74HC93, you would see 4 Flip-Flops. Q0 is alone. Q1, Q2, Q3 are tied together. That’s why we need the external wire.

Internal Block Diagram

The Bill of Materials (BOM)

To build the 4-Bit Counter, you need:

ComponentQuantityValueNotes
74HC9314-Bit Binary CounterCan also use 74LS93
Push Button1Momentary TactileThe Clock Source
LEDs4Red, Green, Blue, YellowTo visualize the bits
Resistor4330ΩCurrent Limiting for LEDs
Resistor110kΩPull-Down for Button
Power15V SourceUSB/Battery
Breadboard1--
Jumper Wires10+Mixed Colors-

The Engineer’s Glossary (Day 9)

  • Binary: Base-2 number system (0s and 1s).
  • Nibble: 4 bits (Half a Byte). Can count 0-15.
  • Byte: 8 bits. Can count 0-255.
  • MSB (Most Significant Bit): The bit with the highest value (The ‘8’ in our 4-bit counter).
  • LSB (Least Significant Bit): The bit with the lowest value (The ‘1’).
  • Ripple Counter: Asynchronous counter where outputs trigger the next stage.
  • Frequency Division: Using counters to slow down a clock signal.
  • BCD (Binary Coded Decimal): A system where 4 bits count 0-9 and then reset (used in digital clocks).

Theory Expansion: Why Hexadecimal?

You might have seen computer codes like #FF00A2. That is Hexadecimal (Base 16). Why do computer scientists use it? Because Binary is annoying to read. Imagine reading 1111000010100010. Your eyes would bleed. Hexadecimal is a shortcut. It groups 4 bits into one character.

  • 0000 = 0
  • 1001 = 9
  • 1010 = A (10)
  • 1011 = B (11)
  • 1111 = F (15)

So 1111 0000 becomes F 0. It is just a way to zip up binary for humans. The computer still sees 1s and 0s.

Alternative Chips: The Counter Family

The 74HC93 is just one member of a huge family.

  • 74HC90 (Decade Counter): Counts 0-9 then resets. Perfect for decimal displays.
  • 74HC163 (Synchronous Counter): Faster, cleaner, no ripple delay. But complex wiring.
  • CD4017 (Decade Counter/Divider): Outputs go High one by one (1, 2, 3…). Great for “Knight Rider” lights.
  • 74HC595 (Shift Register): Not a counter, but converts Serial to Parallel. We will cover this later.

Day 9 Challenge: The Byte

You have built a 4-bit counter (Nibble). Can you build an 8-bit counter (Byte)? Goal: Connect two 74HC93 chips together. Hint: Take the Q3 (8s) output of the first chip and connect it to the Input A of the second chip. Now you have 8 LEDs. You can count from 0 to 255. If you pressed the button once per second, it would take you 4.25 minutes to fill the byte.

Deep Dive: The Carry Bit (How to Count to Infinity)

How does a computer count to a billion? It chains 32 or 64 counters together. But how does Counter A tell Counter B it is full? It uses a Carry Flag. When a counter rolls over from “1111” to “0000”, it sends a pulse. This pulse is the “Carry”. It goes into the Input of the next counter. So: Max Value -> Carry -> Next Counter +1. This simple mechanic allows us to chain infinite chips together to count the atoms in the universe.

Deep Dive: The Year 2038 Problem

Counters have limits. When they hit maximum (1111), they roll over to 0000. This caused the Y2K Bug (2-digit decimal counters rolling from 99 to 00). A similar bug is coming for Linux computers. They count time as “Seconds since Jan 1 1970” using a 32-bit signed binary counter. On January 19, 2038, that counter will hit 0111...111. The next second, it will flip to 1000...000. In signed binary, the first bit is the +/- sign. 1 means negative. So computer clocks will instantly flip to December 13, 1901. Hopefully, by then, we will all be using 64-bit systems!

Common Mistakes (Summary)

  • Assuming Standard Power Pins: 74HC93 uses Pin 5 (VCC) and Pin 10 (GND). This is the #1 reason for failure.
  • Ignoring the Bridge: Forgetting to connect Pin 12 to Pin 1 leaves you with a 1-bit counter and a separate 3-bit counter.
  • Floating Resets: Pins 2 & 3 must be GROUNDED. If they float, the chip thinks you want to reset.
  • Fast Fingers: Can’t see the count? Your button is bouncing 50 times per press. Add a capacitor.

Further Reading

  • Datasheets: Search for “Texas Instruments SN74HC93 datasheet” to see the timing diagrams.
  • History: Look up the “Apollo Guidance Computer”. It used thousands of these logic gates (in NOR form) to fly to the moon.
  • Next Steps: Ready for Day 10? We will build the Knight Rider scanner.

Conclusion

You have tamed the electron. You started with a wire (Day 1). You built a switch (Day 4). You made a decision (Day 7). You remembered a fact (Day 8). And now, you can Count.

0001… 0010… 0011…

This 4-bit counter is the heart of every calculator, every calendar, every timer. But what if we could count… backwards? Or what if we could count to 9 and then stop (Decimal counting)?

Tomorrow, on Day 10, we will combine everything. We will take the 555 Timer (The Heartbeat) and connect it to a Decade Counter (The Brain) to build the classic “Knight Rider” scanner light. We are going to make the LEDs dance.

Safety Logic: Remember, Digital Logic is powerful. But it is also fragile. Static electricity from your finger can fry a CMOS chip like the 74HC93 in a microsecond. Always touch a grounded metal object (like your PC case) before picking up a chip. Respect the silicon.

See you tomorrow.

Comments