🧠Introduction
In this project, we will build an Automatic Smart Dustbin using an ultrasonic sensor and servo motor controlled by an Arduino Nano.
This dustbin opens its lid automatically when a hand is detected near it, making it a hygienic and touch-free solution. It is widely used in smart homes, public places, and is a very popular student project for exhibitions.
🔧 Components Required
- Arduino Nano
- Ultrasonic Sensor (HC-SR04)
- Servo Motor (SG90 or similar)
- Jumper Wires
- Breadboard (optional)
- Dustbin with lid
- Power Supply (5V / Power Bank)
⚙️ Working Principle
The ultrasonic sensor detects the distance of any object (like a hand) placed near the dustbin.
- When hand comes close → Distance decreases
- Arduino detects this change
- Servo motor rotates → Lid opens
- After a delay → Servo returns → Lid closes
👉 This creates a fully automatic touch-free dustbin system
🔌 Circuit Diagram
📌 Connections
Ultrasonic Sensor (HC-SR04)
- VCC → 5V
- GND → GND
- TRIG → D9
- ECHO → D10
Servo Motor
- VCC → 5V
- GND → GND
- Signal → D6
💻 Arduino Code
#include <Servo.h>
#define trigPin 9
#define echoPin 10
Servo myServo;
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
myServo.attach(6); // Servo connected to pin D6
myServo.write(0); // Lid closed position
Serial.begin(9600);
}
void loop() {
// Trigger ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read echo
duration = pulseIn(echoPin, HIGH);
// Calculate distance
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.println(distance);
// If hand detected within 20 cm
if (distance < 20) {
myServo.write(90); // Open lid
delay(3000); // Keep open for 3 seconds
myServo.write(0); // Close lid
}
delay(200);
}
🛠️ Step-by-Step Construction
- Connect ultrasonic sensor to Arduino Nano
- Connect servo motor to pin D6
- Upload the code using Arduino IDE
- Fix servo motor on dustbin lid
- Connect lid to servo horn properly
- Power the circuit
- Test by placing your hand near the sensor
🎯 Applications
- Smart homes
- Hospitals (hygienic waste disposal)
- Public places
- School and college projects
✅ Advantages
- Touch-free operation
- Improves hygiene
- Easy to build
- Low cost
- Expandable system
🚀 Future Improvements
- Add IR sensor for better detection
- Add LCD display
- Add IoT monitoring (ESP8266)
- Add voice alert system
📌 Conclusion
The Arduino Smart Dustbin is a practical and innovative project that demonstrates real-world automation using sensors and actuators. It is an excellent project for beginners to learn about ultrasonic sensing and servo motor control.