15micro:bit · MakeCode 60 minutes
Paper-flap capstone
Toggle a light paper flap slowly with button A.

Lesson goal: Button A toggles an opened state and moves the servo slowly between CLOSED_US 1400 and OPEN_US 1600 in steps of at most 10 µs every 30 ms; B requests stop.
Open MakeCodeSection 1
Understand
- state
- busy guard
- stop flag
- commanded vs actual
- 1A toggles a light paper flap open or closed, slowly.
- 2The display shows the commanded state, not the real position.
- 3B stops the pulses; unplugging motor power is the real stop.
Safety first
- Adult setup required. The servo needs an external REGULATED 5 V supply rated at least 1 A, with a suitable insulated connector. This may be an extra item not in the box.
- External 5 V positive goes ONLY to the servo's positive lead. It connects to no micro:bit pin, not the 3V ring, and not the battery connector.
- External supply negative connects to the servo ground AND to the micro:bit GND, so both share a reference.
- The micro:bit stays powered by USB. Never power a servo from a pin or the 3V ring.
- Lead colours are usually red = positive, brown/black = ground, orange/yellow = signal, but markings on your servo override colours.
- Clamp the servo down. Test first with the horn removed. The first command can make it jump.
- If it binds, buzzes, heats or stalls: disconnect motor power at once. Turn off both supplies before any rewiring or fitting the horn.
- Both supplies off before mounting the flap or horn.
- Light paper only. Parent design review needed before any future mechanism; plan a manual release.