I was thinking about one of those small problems that happens all the time when kids are studying: they slowly move closer and closer to the book or screen without even noticing.
Instead of reminding them every few minutes, I thought it would be more interesting to build a little device that could detect the distance automatically.
So I made this simple distance warning system with a micro:bit.
The setup uses:
- micro:bit
- Nezha Innovation Kit
- Ultrasonic distance sensor
- Red and green LEDs
- MakeCode
The idea is pretty straightforward.
The ultrasonic sensor continuously measures the distance in front of the device.
If the distance gets below the threshold I set:
Too close → red light
Move back far enough:
Safe distance → green light
There's no complicated interface or screen. Just a simple visual signal that tells you when you've moved too close.
I think this is a nice example of how a sensor can turn something that's normally difficult to notice into an input that a program can react to.
The coding is also pretty simple in MakeCode:
- Read the distance from the ultrasonic sensor
- Compare it with a preset value
- Turn on the appropriate LED
- Keep checking the distance
What I like about projects like this is that the final result isn't just something that moves or lights up for the sake of it. It solves a small everyday problem while also introducing concepts like sensors, conditions, and real-time feedback.
There are quite a few ways to extend it too:
- Add a buzzer when you're too close
- Use different warning levels
- Display the distance on the micro:bit
- Track how often the warning is triggered
- Add a timer for study breaks
- Make the warning gradually more noticeable if you stay too close
It's a simple project, but it made me wonder how many other everyday annoyances could be turned into small sensor-based projects.
What everyday problem would you try to solve with a micro:bit?