⚡ Spark Academy53 lessons

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.

lesson 3 of 3 in this unit

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.

each stage divides frequency by 2 · n stages count 0 … 2ⁿ−13 stages: divide by 8, count 0–7
The summit view

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.
2.0 Hz
Frequency division
Q0 runs at half the clock, Q1 at a quarter, Q2 at an eighth — read it off the scope
Where you've seen this clock
a 555 astable makes a perfect clock source — your blinker circuit can drive this counter

Check your understanding

Q1. An SR latch remembers its state because…

Q2. A D flip-flop copies D to Q…

Q3. A 3-bit counter counts from 0 up to…

Q4. Feed a 32 768 Hz crystal through 15 divide-by-two stages and you get…