I’ve been learning how to use themicro:bit together with the Spiker:bit, and I wanted to build a simple project that helps me understand both the hardware and the MakeCode logic at the same time. This project is my version of a “muscle-powered D20”. Basically, I flex my muscle, and the micro:bit rolls random number from 1 to 20.
It’s a fun and very approachable way to get started with bio-signals, conditionals, and randomness in MakeCode.
What I’m LearningWith this project, I’m focusing on three main ideas:
- How the Spiker:bit reads muscle (EMG) signals
- How the micro:bit processes analog data in MakeCode
- How to use logic (
if/else) and randomness to create interaction
The Spiker:bit measures electrical activity from my muscles (EMG signals). When I flex, the signal increases. The micro:bit reads this signal as a numeric value called muscle power signal.
In my program:
- When the signal is low, nothing important happens
- When the signal is high (above a threshold), I trigger a die roll
- micro:bit
- Spiker:bit + 2x AA Batteries
- EMG electrodes (on my forearm or bicep)
- Orange cable with alligator clips
Note: Before starting this project make sure to select Spiker:bit extension in MakeCode editor.
Here’s how I structured the program:
1. Start Recording Muscle Activity
on start → start muscle recordingThis initializes the Spiker:bit so it begins reading EMG signals.
2. Continuously Monitor the Signal
forever → print muscle power signalI print the signal so I can see live feedback and adjust my threshold.
3. Detect a Muscle Flex
if muscle power signal < 50 → clear screen
else → show random number (1 to 20)This is the core idea:
- I chose 50 as a threshold (this may vary depending on the user)
- When I flex my muscle, the signal goes above 50
- That triggers the “die roll”
The micro:bit uses:
pick random 1 to 20This simulates a D20 roll, like in tabletop games (Dungeons & Dragons style).
Each time I flex, I get a new random number between 1 and 20 displayed on the LED screen.
EMG signals are different for everyone. Before using the project, I:
- Watched the printed signal values
- Relaxed my muscle (noted baseline)
- Flexed strongly (noted peak)
- Picked a threshold in between
For me, ~50 worked well, but this might need adjusting.
Why This Project Is UsefulI like this project because it combines:
- Biology
- Electronics (Spiker:bit + micro:bit)
- Programming (logic + randomness)
And it’s simple enough for beginners to understand while still feeling interactive and “alive.”
Final ThoughtsThis project helped me understand how physical signals from my body can directly control digital behavior.
If you’re just starting with Spiker:bit and micro:bit, this is a great first project to explore both hardware and programming in a fun way.









Comments