Source: https://mokxi.com/learn/path/build-marble-machine
Updated: 2026-11-20

All paths

# Build a marble machine

A 28BYJ-48 lift stepped from its coil table, a servo gate that routes, a debounced marble counter, a WS2812 count bar and a jam alarm, for a machine that runs forever.

Arduino Uno R3 Free 6 lessons 6 h 3 chapters 1,654 XP Robotics · Intermediate +150 XP

0 of 6 done

Start the course free A lift Lesson plan for teachers

What you will build

## 3 projects, built step by step

6 lessons in 3 chapters, about 6 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.

Chapter 1 project

### Gates

A servo gate at the top sends each marble down track A or B. Follow a route pattern, change it from the Serial Monitor, and make a pattern the machine starts with.
Open it in the simulator

Chapter 2 project

### Light effects

Eight WS2812 LEDs on one wire: a bar that fills with each marble in the color of its track. Read the strip, fill it faster, and keep the current in check.
Open it in the simulator

Chapter 3 project

### Project: an endless run

Run the machine for real: the lift on, marbles round and round, stats as it goes. Then add a lap of honor every ten marbles and a count for each track.
Open it in the simulator

The map

## Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

## Lift and gate

The stepper’s steps, speed and stall, and a gate that follows a pattern.

Open 236 XP

### A lift

A 28BYJ-48 stepper turns a screw that lifts a marble a turn. Move it by steps, work out 2048 steps a turn, time the steps from rpm, stall it by asking too much, and ramp it up to beat the stall.

0 of 6 steps

Start What is in it

Project Locked 348 XP

### Gates

A servo gate at the top sends each marble down track A or B. Follow a route pattern, change it from the Serial Monitor, and make a pattern the machine starts with.

0 of 4 steps

4 questions, graded as you go.

Chapter 2

## Count and show

Every marble counted once, on an interrupt, and shown on the strip.

Locked 205 XP

### Counting marbles

A marble crosses the beam in a few milliseconds. Count on an interrupt so none is missed, debounce a wobbling marble, break the debounce to see why it matters, and read the rate.

0 of 5 steps

Project Locked 348 XP

### Light effects

Eight WS2812 LEDs on one wire: a bar that fills with each marble in the color of its track. Read the strip, fill it faster, and keep the current in check.

0 of 4 steps

3 questions, graded as you go.

Chapter 3

## Run forever

A jam alarm tied to the lift’s speed, then the endless run.

Locked 205 XP

### Jam detection

A stepper never knows it is stuck. The counter does: no marble for a turn and a half means a jam. Catch one, see it in red, clear it, and tie the timeout to the lift’s speed.

0 of 5 steps

Project Locked 312 XP

### Project: an endless run

Run the machine for real: the lift on, marbles round and round, stats as it goes. Then add a lap of honor every ten marbles and a count for each track.

0 of 4 steps

3 questions, graded as you go.

Syllabus

## Every lesson in the course

All 6 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

### Lift and gate

- A lift A 28BYJ-48 stepper turns a screw that lifts a marble a turn. Move it by steps, work out 2048 steps a turn, time the steps from rpm, stall it by asking too much, and ramp it up to beat the stall.
- Gates A servo gate at the top sends each marble down track A or B. Follow a route pattern, change it from the Serial Monitor, and make a pattern the machine starts with.

Chapter 2

### Count and show

- Counting marbles A marble crosses the beam in a few milliseconds. Count on an interrupt so none is missed, debounce a wobbling marble, break the debounce to see why it matters, and read the rate.
- Light effects Eight WS2812 LEDs on one wire: a bar that fills with each marble in the color of its track. Read the strip, fill it faster, and keep the current in check.

Chapter 3

### Run forever

- Jam detection A stepper never knows it is stuck. The counter does: no marble for a turn and a half means a jam. Catch one, see it in red, clear it, and tie the timeout to the lift’s speed.
- Project: an endless run Run the machine for real: the lift on, marbles round and round, stats as it goes. Then add a lap of honor every ten marbles and a count for each track.

Keep going

## The next course on your track

Build a marble machine is part of the maker track, a ladder of courses from zero to expert.

Next course

### Build a moon phase lamp

Learn why the Moon has phases, work them out from any date, and build a lamp that shows tonight's Moon in the dark.
Open the next course

Track

### Maker track

Follow the starter kit you already own, then build a claw machine, a balance bot, a handheld console or an LED cube, each a short course checked by the simulator.
See every course on the track

Kits

## Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

### Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kit

Questions

## About Build a marble machine

Is Build a marble machine free?

Yes. All 6 lessons of Build a marble machine are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Arduino Uno R3?

No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Build a marble machine take?

About 6 hours: 6 lessons in 3 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Gates, Light effects and Project: an endless run.

Where do I start?

With "A lift", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.
