Build a marble machine lesson plan
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.
Objectives and materials
By the end, students can
- The stepper’s steps, speed and stall, and a gate that follows a pattern.
- Every marble counted once, on an interrupt, and shown on the strip.
- A jam alarm tied to the lift’s speed, then the endless run.
Materials for the whole unit
- Addressable RGB LEDs
- Arduino Uno R3
- Hobby servo
- Photo interrupter, slot
- Stepper motor, 28BYJ-48 with ULN2003
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
Lift and gate
The stepper’s steps, speed and stall, and a gate that follows a pattern.
| Lesson | Time | What students do |
|---|---|---|
| A liftA 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. | 75 min |
|
| GatesA 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. | 50 min |
|
Materials
- Addressable RGB LEDs
- Arduino Uno R3
- Hobby servo
- Photo interrupter, slot
- Stepper motor, 28BYJ-48 with ULN2003
Check for understanding
Each student finishes "Gates" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A pattern it starts with".
Count and show
Every marble counted once, on an interrupt, and shown on the strip.
| Lesson | Time | What students do |
|---|---|---|
| Counting marblesA 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. | 65 min |
|
| Light effectsEight 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. | 50 min |
|
Materials
- Addressable RGB LEDs
- Arduino Uno R3
- Hobby servo
- Photo interrupter, slot
- Stepper motor, 28BYJ-48 with ULN2003
Check for understanding
Each student finishes "Light effects" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "All of them".
Run forever
A jam alarm tied to the lift’s speed, then the endless run.
| Lesson | Time | What students do |
|---|---|---|
| Jam detectionA 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. | 65 min |
|
| Project: an endless runRun 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. | 50 min |
|
Materials
- Addressable RGB LEDs
- Arduino Uno R3
- Hobby servo
- Photo interrupter, slot
- Stepper motor, 28BYJ-48 with ULN2003
Check for understanding
Each student finishes "Project: an endless run" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Show it".
Teach this unit as a class
Start a class from this course and its 6 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.