🗑️ Touchless Smart Dustbin
Keep your hands clean. A servo automatically opens the lid when it detects your hand.
Overview
This is a classic utility project. An ultrasonic sensor constantly pings for objects within 30cm. If it detects a hand, it sweeps a servo to open the lid and holds it open for 3 seconds.
What you'll learn: Ultrasonic timing, servo mechanical linkages, and delay-based state holding.
Estimated time: 2-3 hours. Difficulty: ⭐⭐ Easy.
Components Needed
| Component | Specification | Qty | Notes |
|---|---|---|---|
| Arduino Uno R3 | 5V | 1 | |
| HC-SR04 | Ultrasonic | 1 | |
| Servo Motor | SG90 | 1 | For light lids |
| Dustbin | Small/Desktop size | 1 | With a hinged lid |
Step-by-Step Tutorial
1
Mount Sensor
Cut two holes in the front of the bin for the ultrasonic "eyes".
2
Mount Servo
Glue the servo near the hinge. Attach a stiff wire or paperclip from the servo horn to the lid.
3
Upload Code
Upload the logic. Adjust the opening angle so the lid doesn't snap backward.
If the lid is heavy, you will need a standard-sized servo (like an MG996R) and a separate 5V power supply, as the Arduino cannot provide enough current.
Code / Configuration
smart_dustbin.ino
INO
// Smart Dustbin
#include <Servo.h>
Servo lidServo;
int trigPin = 9;
int echoPin = 10;
long duration, distance;
void setup() {
lidServo.attach(8);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lidServo.write(0); // Closed position
}
void loop() {
digitalWrite(trigPin, LOW); delayMicroseconds(2);
digitalWrite(trigPin, HIGH); delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration / 2) / 29.1;
if (distance < 30) {
lidServo.write(90); // OpenReviews & Ratings
—0 reviews
Sign in to leave a review
Loading reviews...