radio.setGroup(1);
input.onGesture(Gesture.Shake, () => {
radio.sendNumber(1) // Trigger on shake
})
• Hardware: Embed the micro:bit into the aluminum can and connect the battery pack.
2. Receiver & LED Circuit (Basic Version)
• Circuit Setup:
• Connect the LED anode to micro:bit’s P0 pin via a 220Ω resistor; cathode to GND.
• Receiver Code:
radio.onReceivedNumber(function (receivedNumber) {
pins.digitalWritePin(DigitalPin.P0, 1) // Light up LED
basic.pause(1000)
pins.digitalWritePin(DigitalPin.P0, 0)
})
3. Test & Enhance
• Basic Demo: Swish the wand to trigger LED flashes.
• Pro Tip: Program rainbow effects with Neopixel strips (additional code required).
From Light Show to Levitation
1. Levitation Upgrade (Optional):
• Hardware Mod: Add a motor, MOSFET, and fan using the expansion pack components.
• Code Adjustment: Redirect P0 pin control from LED to motor.
• Testing: Place a feather above the fan and activate it with wand gestures.
# Advanced Code: Motor Control
if msg == "levitate":
pin0.write_digital(1) # Start motor
sleep(5000)
pin0.write_digital(0)
2. Creative Mods:
• Use servos to auto-flip a "magic book."
• Add voice modules for spell-casting sound effects.
Why It Matters
• Beginner-Friendly: Build the basic version in 30 minutes with minimal components.
• Endless Possibilities: Scale up to motorized projects or IoT integrations.
• STEAM Integration: Combines physics (circuits), art (light design), and storytelling (magic themes).
Epilogue: Your Magic, Your Rules
Whether lighting up LEDs or levitating feathers, the true power of your micro:bit lies in
creativity. Master the basics, then conjure your own enchantments!