TRASH-BOT. (Arduino Auto Open Close Trash Bin)

16K5519

Intro: TRASH-BOT. (Arduino Auto Open Close Trash Bin)

Everything's getting smarter right? So why not your Trash Bin? This trash bin Opens and Closes its lid if it sees any Rubbish in front of it. You just need to bring the rubbish to it and it'll open automatically and will wait for you to feed it more then after a certain delay it'll close automatically. Watch the video to see exactly what it can do.

Post on https://www.blogger.com/blogger.g?blogID=731326532...

Let's get started.

STEP 1: Parts You'll Need

1.Arduino (any board)

2.Servo motor (i'm using micro servo sg90)

3. HCsr04 ultrasound sensor

4. Servo arms (beside the servo in pic2)

3. Card Board (just slice piece)

4. Trash Bin

Buy electric components on utsource.net

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

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.

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 .

STEP 5: The Code

Code link https://github.com/ashraf-minhaj/Trash-bot

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.

#include<Servo.h>
Servo servo;
int const trigPin = 6;
int const echoPin = 5;
void setup()
{
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
    servo.attach(3);
}
void loop()
{       int duration, distance;
digitalWrite(trigPin, HIGH); 
delay(1);
digitalWrite(trigPin, LOW);
// Measure the pulse input in echo pin
duration = pulseIn(echoPin, HIGH);
// Distance is half the duration devided by 29.1 (from datasheet)
distance = (duration/2) / 29.1;
// if distance less than 0.5 meter and more than 0 (0 or less means over range) 
if (distance <= 50 && distance >= 0) {
	servo.write(50);
    delay(3000);
} else {
	
	servo.write(160);
}
// Waiting 60 ms won't hurt any one
delay(60);
}

STEP 6: You Are Done

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]

12 Comments

Hello, what should we do after downloading the zip file from the link
Unzip it, open the ino file (first download arduino.ide) then upload the code to your arduino.
Hi, I uploaded the code in arduino.ide . It gave an error message that

Arduino:1.8.13 Hourly Build 2020/03/25 03:33 (Windows 10), Kart:"Arduino Uno"
Trash_bot_Code.ino:36:2: error: stray '\357' in program
}
^
Trash_bot_Code.ino:36:3: error: stray '\273' in program
}
^
Trash_bot_Code.ino:36:4: error: stray '\277' in program
}
^
C:\Users\lenovo\Desktop\ardunio\Trash_bot_Code.ino\Trash_bot_Code.ino.ino: In function 'void setup()':
Trash_bot_Code.ino:10:1: error: a function-definition is not allowed here before '{' token
{
^
Trash_bot_Code.ino:16:13: error: a function-definition is not allowed here before '{' token
void loop() {
^
Trash_bot_Code.ino:36:1: error: expected '}' at end of input
}
^
exit status 1
stray '\357' in program
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

what should I do
It's missing a closing angle bracket '}'
It says you have to put a curly brace '{' in a line. Did you copy the code from online or download it?
I'd suggest to download the code from github then unzip and upload using Arduino.ide

Sweet! Great way to style up the trash, I like it!