Project tutorial
Arduino Trash-Bot (Auto Open/Close Trash Bin)

Arduino Trash-Bot (Auto Open/Close Trash Bin) © GPL3+

This trash bin opens and closes its lid if it sees any rubbish in front of it and will close automatically after certain delay.

  • 7 respects

Components and supplies

Apps and online services

About this project

We'll be making this Trash Robot, see the video.


Step 2: Build the Circuit

The circuit is so easy. As the servo and sonar only takes less power you can just power them directly from arduino 5v source. Just remember to power the Arduino with more than 7.4 V DC or at least 7v.

Servo data (yellow) to pin 3 of arduino

Servo vcc (red) to 5v of Arduino

Servo ground (black/gray) to Arduino Gnd

Sonar sensor trig to Arduino 6

Sonar sensor echo to Arduino 5

Vcc to Arduino 5v

Gnd to Arduino Gnd

Add TipAsk QuestionCommentDownload

Step 3: Connect the Servo Arm

Just take this servo arm and connect it to a long card board piece with hot glue or other glues. You can also use Ice Cream stick instead of Card Board. Then connect the long servo arm to servo motor.

Add TipAsk QuestionCommentDownload

Step 4: Add Servo & Sonar Sensor to the Trash BIn

Connect he sonar sensor facing up to the Bin like this. And then add the Servo motor like this on pic 2&3, so that the servo can rotate to up.

Add TipAsk QuestionCommentDownload

Step 5: The Code

Code link

I've programmed the arduino so that if it sees any rubbish (literally anything) in 50 cm range the servo goes to 50 degrees and hits the upper lid of the bin, so that the upper lid gets open and then waits for three seconds then automatically turns to 160 degrees and thus the upper lid gets closed. Thus you see an Auto Open Close TRASH-BOT.

Servo servo;
int const trigPin = 6;
int const echoPin = 5;
void setup()
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT);     
void loop()
int duration, 
digitalWrite(trigPin, HIGH); 
digitalWrite(trigPin, LOW);// Measure the pulse input in echo 
duration = pulseIn(echoPin, HIGH);// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;
if (distance <= 50 && distance >= 0)
else {		

So now just power the arduino with more than 7v and you have a trash bin robot.

Thank you.

[If you like my Works please support me by Subscribing my YouTube channel]



arduino trash-bot.Circuit
Trash bot lonevo15lt


Add projectSign up / Login