Project 11 — The Marble Counting Machine

Text written by Claude Fable 5 (claude-fable-5).

Project 11 — The Marble Counting Machine

The one idea: a machine with no brain can count. Every marble that rolls past nudges the invisible eye, and a lit dot hops one step along a row of ten LEDs. The machine never loses track, never gets bored, never counts the same marble twice.

The new part is the CD4017, a chip as cheap and as classic as the 555: ten outputs, exactly one high at a time, and every clock pulse moves the “on” to the next one. Wire ten LEDs to it and you have a dot that steps 0…9 — a counting machine the child can see think.

How does a 16 mm marble use a 5 mm slot? It doesn’t go through it — it flicks a flag that does. A little cardboard flag on a straw hinge hangs into the marble’s path; the flag’s top tab rests inside the opto slot. A marble rolls by, tips the flag, the tab swings out of the slot, the beam blinks through — one count — and the flag swings back to block it again. (If you’d rather skip the mechanics: a wide DIY light gate as in Project 8 across the track works too. But the flag is honestly the fun part.)

What you need

Build it — stage 1: the flag mechanism

  1. Cut a cardboard flag shaped like a lowercase T rotated: a tall tab on top, a wide paddle at the bottom.
  2. Hinge it just above the track — skewer through a straw taped across two supports, flag taped to the skewer, or simply a floppy tape hinge — so the paddle hangs into the marble’s path and the top tab sits inside the opto slot.
  3. Mount the opto (blu-tack) so that at rest the tab blocks the beam, and a rolling marble tips the paddle enough to swing the tab clear.
  4. Tune until a marble reliably makes the flag do one clean flip-flop: tip, swing back, settle. A small blob of blu-tack low on the paddle makes it bottom-heavy so it settles fast instead of waggling.

This is 15 minutes of pure mechanical play and it’s where the child does the engineering. Marble in, flag flips — you can already see the event; now we’ll make the circuit see it.

Build it — stage 2: the eye and the counter

The eye, wired so that light = HIGH (the Project 8 way up): opto LED side + → 220 Ω → LED → GND; phototransistor collector+, emitter → the signal node, node → 10 kΩ → GND. At rest (tab in slot) the node sits LOW; each marble makes a brief HIGH pulse. Add the calming filter: 10 kΩ in series from the node to the 4017’s clock pin, and 10 µF from that pin to GND — it irons out any last flag wobble so one marble is one count.

The CD4017 (16-pin DIP; pin 1 is left of the notch, as always):

  1. Pin 16+, pin 8 → GND.
  2. Pin 13 (clock inhibit) → GND. Pin 15 (reset) → GND through 10 kΩ, and through the pushbutton to + — pressing it sends the dot home to zero.
  3. Pin 14 (clock) ← the filtered signal node.
  4. The ten outputs, in counting order, are pins 3, 2, 4, 7, 10, 1, 5, 6, 9, 11 (yes, scrambled — chip-internal layout reasons; label them 0–9 with a marker on masking tape). LED anode to each output.
  5. The one-resistor trick: since only one output is ever high, all ten LED cathodes join into one rail → single 470 Ω → GND.

Press reset: LED 0 lights. Roll a marble: the dot hops to 1. Roll nine more and watch it walk the whole row and wrap around to 0 — the machine counts in circles, just like the ones-digit of a car’s odometer.

What to say to the child

“Let’s count the marbles — but not us: the machine will. Every marble that rolls past bumps the little flag, the flag uncovers the secret light for a blink, and that blink tells the chip: one more! Watch the light hop along… three… four… five. It never forgets and never counts double. Try to trick it! Roll two marbles almost together — did it catch both? Now roll ten and watch what happens after nine… it goes back to zero, just like when you count on your fingers and run out — you’d need another hand. Want to give the machine another hand?”

For you — the physics

Try it with the Arduino — a real scoreboard

The same filtered signal into a digital pin, count rising edges, print the total — to the Serial monitor or whichever display you have at hand. The Arduino adds what the 4017 can’t: arithmetic. Marbles per minute, time gaps between marbles (“which ramp height makes them come fastest?”), a beep at a target count. Ten lines of code; the sensor side doesn’t change at all.

Try next

← Back to Read Me First.