In this exciting hands-on project, students will build a Smart Dustbin that opens automatically when someone comes close, just like modern touchless bins found in malls, airports, and hospitals. Using the Calliope Mini and an ultrasonic distance sensor, learners will understand how sensors detect objects, how actuators respond, and how code controls real-world actions. This project teaches basic robotics, environmental hygiene, and how technology encourages cleaner, healthier living spaces. By the end, students will proudly create a working automated dustbin that helps reduce contact with germs while making waste disposal more fun and futuristic!
What You will Need
| Component | Purpose |
|---|---|
| Calliope Mini V3 | Main controller that runs the smart dustbin program |
| Ultrasonic Sensor (HC-SR04) | Detects how close a hand or object is |
| Micro Servo Motor (SG90) | Opens and closes the dustbin lid |
| Jumper Wires | Connect sensors and servo to the Calliope |
| Cardboard Dustbin or Small Container | The physical bin body |
| USB Cable | For coding and uploading the program |
Understand the Circuit
Connect the ultrasonic sensor:
VCC to 3V on Calliope
GND to GND
TRIG pin to Pin P0
ECHO pin to Pin P1
Connect the servo motor:
Brown wire (GND) to GND
Red wire (VCC) to 3V
Orange wire (signal) to Pin P2
The ultrasonic sensor measures how close a hand is. When the distance is small enough, the Calliope sends a signal to the servo, lifting the lid automatically.
Circuit Diagram With Breadboard
Circuit Diagram Without Breadboard
The Project Code - MakeCode Blocks
Follow these steps carefully to open and explore the project in MakeCode for Calliope Mini:
When you open the link, you will see a few colorful blocks.
Next, click Edit Code tab to be directed to the MakeCode editor
Upload the Code
Understand the Code
| Code Block | What It Means |
|---|---|
sonar.ping(P0, P1) | Sends and receives sound waves to measure distance |
if (distance < 15) | Checks if a hand/object is closer than 15 cm |
servos.P2.setAngle(90) | Turns the servo to open the lid |
servos.P2.setAngle(0) | Returns the servo to close the lid |
basic.showIcon() | Shows a face depending on bin activity |
basic.pause(200) | Reduces sensor reading frequency for stability |
Troubleshooting the code
Lid not opening?
Check if the servo’s signal wire is firmly connected to P2.Sensor reading 0 cm constantly?
Ensure TRIG is on P0 and ECHO is on P1—these must not be swapped.Servo shaking or jittering?
Use only 0° or 90° angles; avoid rapid continuous changes.Bin opens randomly?
Increase distance threshold from 15 cm to 20–25 cm.
What You Have Learned
How ultrasonic sensors detect distance
How servo motors move mechanical parts
How automation improves hygiene and convenience
How microcontrollers read sensor inputs and trigger actions
How to design simple robotics systems using Calliope Mini
Extra Challenge!
Add a buzzer that beeps when the bin opens.
Use LEDs: green when the bin is ready, red when full.
Add a “bin full” sensor using a light sensor or second ultrasonic sensor.
Decorate the bin as a robot character, give it eyes, a mouth, and personality!
Record sound clips (“Thank you!”) and play them when trash is dropped.
AI Extensions
Students can use TinyML with Edge Impulse to train a small model that recognizes hand wave patterns or gestures.
A simple upgrade: The dustbin only opens when the model detects a wave gesture—making the bin smarter, safer, and more interactive.
