Smart Dustbin With Ultrasonic Sensor and Servo
by Ameya Angadi in Circuits > Arduino
37 Views, 0 Favorites, 0 Comments
Smart Dustbin With Ultrasonic Sensor and Servo

Build a smart dustbin that opens automatically using an ultrasonic sensor and an Arduino UNO.
Supplies
- Arduino Uno
- SG90 Servo Motor
- Male-Male Jumper Wires
- Male-Female Jumper Wires
- HCSR04 Ultrasound Sensor
Connecting the Ultrasonic Sensor (HC-SR04)
- Connect the VCC pin of the HC-SR04 sensor to the 5V pin on the Arduino.
- Connect the GND pin to the Arduino's ground.
- Connect the Trig pin to digital pin 5 on the Arduino.
- Connect the Echo pin to digital pin 6 on the Arduino.
Setting Up the Servo Motor for Lid Control:
- Connect the servo motor’s VCC (red wire) to the Arduino’s 5V pin.
- Connect the GND (black wire) to the Arduino's ground.
- Connect the servo signal wire (usually orange or yellow) to digital pin 9 on the Arduino.
Writing the Code:
In the code, the ultrasonic sensor measures distance, and if the distance is within a specified range (e.g., 20 cm or less), the servo motor rotates to open the dustbin lid. The lid will close after a short delay of 3.5 seconds.
Testing the Setup:
Place the dustbin setup in front of you, ensuring the ultrasonic sensor points outward.
Move your hand or an object close to the sensor (within 20 cm) to see the lid open.
After a delay, the lid should automatically close.
Troubleshooting Tips:
Ensure the servo motor and ultrasonic sensor are correctly wired to avoid inaccurate readings.
If the lid does not open smoothly, adjust the servo angle in the code for an optimal opening range.
Want to see this project in action?
Watch my YouTube video where I demonstrate how the smart dustbin works step-by-step!
Watch the Video for Step-By-step Tutorial

Conclusion:
By completing this project, you've built a simple yet effective smart dustbin that opens its lid automatically when needed. You can adjust the range or add features like LED indicators to make it more interactive. Check out my other projects for ideas to expand your smart dustbin system!
If you want to explore more, check out my profile for related projects, and don’t forget to follow me for updates on new tutorials and advanced projects!
Code
Downloads
Smart Dustbin Connections

Follow this circuit diagram to make this project.