Memory & Counters
Cross two gates and the circuit remembers. Clock it, chain it, and you've built a counter — and met the idea behind RAM.
Builds on: 7.1 Binary & Logic Gates3.3 The 555 Timer
Feedback becomes memory
Every circuit so far forgets its inputs instantly. Now take two NAND gates and cross their outputs back into each other’s inputs — feedback again, but digital. The result, an SR latch, has two stable states and stays in whichever one it was last pushed toward: pulse Set and the output locks at 1; pulse Reset and it locks at 0. Between pulses it holds — indefinitely. That is one bit of memory, conjured from nothing but wiring.
Adding a clock: the flip-flop
Computers need millions of bits changing in lock-step, not whenever inputs twitch. The D flip-flop gates a latch behind a clock: it copies its D input to its Q output only at the clock’s rising edge and ignores everything in between. A row of flip-flops sharing one clock is a register — where your CPU holds the numbers it’s working on. And the clock itself? A square wave from an oscillator… your 555 (Lesson 3.3) is precisely such a clock, just slower than a CPU’s billions of ticks.
Counters: memory + arithmetic
Wire a flip-flop to toggle on every falling edge of its input and its output runs at half the input frequency — a divide-by-two. Chain three and the outputs Q0 Q1 Q2, read as a binary number, march 0,1,2,…7 and wrap: a 3-bit counter. This one structure is your digital watch (32 768 Hz crystal divided by 2 fifteen times = exactly 1 Hz), your kitchen timer, and the program counter stepping your CPU through instructions.
Gates (combinational logic) compute; flip-flops (sequential logic) remember; a clock marches them forward together. Every computer ever built — including the one running this page — is those three ideas, repeated billions of times. From here, microcontrollers are the natural next mountain.
⚡ Lab — The Bit That Remembers
A 3-bit ripple counter on a live clock, with every waveform on the scope.
- Watch Q0 run at half the clock, Q1 at a quarter, Q2 at an eighth — frequency division, visibly.
- Read the LEDs as binary and check they match the decimal readout through a full 0–7 lap.
- Pause the clock and step with Pulse — the state holds between pulses. That's memory.