This project journey follows the evolution of a simple social-distancing idea into a fully realized "Hug Avoider" wearable. Written from my perspective, it’s designed to take you from basic block coding into the professional-grade world of MicroPython.
As a maker and educator, I’m always on the hunt for "low floor, high ceiling" projects—those that are easy enough for a beginner to start in an afternoon but deep enough to keep an experienced coder engaged.
I embarked on a multi-stage project using the 4tronix EggBit. What started as a simple social-distancing experiment turned into a transition from blocks to text-based code. Whether you're a teacher, a parent of a young coder, or a fellow maker, here is the full evolution of the "Hug Avoider."
The Hardware: Meet the EggBit
The foundation of this project is the
[INSERT IMAGE: The 4tronix EggBit board showing the front face and sensor mounting]
It breaks out the micro:bit’s pins into a few key components:
HC-SR04P Ultrasonic Sensor: These act as the "eyes."
LED strip: Perfect for mood lighting or status indicators.
A Piezo Buzzer: For audible alerts.
Lanyard Hole: Essential for making it a true wearable!
For the makers and "under-the-hood" tinkerers, here is the breakdown of how the EggBit maps to the micro:bit’s pins. This is essential if you plan on writing custom libraries or branching out from the standard extensions.
| Component | Hardware Model | micro:bit Pin | Notes |
| Distance Sensor | HC-SR04P (3V version) | Pin 13 (Trigger) Pin 14 (Echo) | Uses standard ultrasonic pulse-timing logic. |
| LED Strip | Addressable RGB LEDs | Pin 8 | Compatible with the neopixel library. |
| Buzzer | Passive Piezo | Pin 15 | Can play tones, melodies, or custom frequencies. |
| Ee | |||
| Power | 3V DC | Battery Connector | Powered via the micro:bit’s battery pack or USB. |
Maker Tip: If you're looking to pick one up, you can grab a
, or if you're running a classroom or a club, they offer a single EggBit here to save a bit of budget. Three-Pack Special
Phase 1: The "Low Floor" (MakeCode Blocks)
To get the project off the ground, I started with Microsoft MakeCode. This is the perfect entry point for students. Using the dedicated EggBit extension, you can get a "social distancing" alarm running in minutes.
The logic is straightforward: If the ultrasonic sensor detects an object closer than 50cm, the LED strip turns red and the buzzer sounds a warning.
In my
Phase 2: Pulling Back the Curtain (MicroPython)
While blocks are great, they hide the "magic." To really understand how sensors communicate with a computer, I decided to rewrite the project in MicroPython.
For this, I highly recommend using the official
In
Phase 3: Handling Real-World Bugs
No project is complete without troubleshooting. In the final phase, I ran into a common maker hurdle: sensor reliability.
When using MicroPython, the timing doesn't need to be precise. If the sound pulse doesn't hit a solid surface (like hitting a soft, sound-absorbing sweater),
In utime.sleep_ms(10) between pings . I also added a bit of personality by using the micro:bit’s 5x5 LED matrix to display an "angry" face when someone enters the personal space zone.
Why This Project Wins for STEM
This journey from a simple "anti-hug" device to a refined Python-powered wearable covers the entire engineering design process:
For Teachers: It’s a perfect curriculum arc. Start with blocks in the junior years and move to the Python distance formula as they progress.
For Parents: It’s an affordable, tactile project. Seeing a child wear something they actually coded is the ultimate "lightbulb" moment.
For Makers: It’s a great lesson in the limitations of hardware and how to write "defensive" code that doesn't crash when sensors behave unexpectedly.
If you're ready to dive deeper into the code or the specific hardware challenges I faced, check out the original posts here:
No comments:
Post a Comment