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

10,573

51

12

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

About: A Computer Science and Engineering student and a Hobbyist. love to make robots,electric devices,diy things and Programming them by Myself. My youtube channel https://www.youtube.com/fussebatti Follow me on gi…

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]

Microcontroller Contest

Participated in the
Microcontroller Contest

1 Person Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

12 Discussions

0
tugceguler
tugceguler

Reply 6 months ago

Hello, what should we do after downloading the zip file from the link

0
Ashraf Minhaj
Ashraf Minhaj

Reply 6 months ago

Unzip it, open the ino file (first download arduino.ide) then upload the code to your arduino.

0
tugceguler
tugceguler

Reply 6 months ago

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

0
Ashraf Minhaj
Ashraf Minhaj

Reply 4 months ago

It's missing a closing angle bracket '}'

0
Ashraf Minhaj
Ashraf Minhaj

Reply 6 months ago

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

0
Ashraf Minhaj
Ashraf Minhaj

Reply 6 months ago

Well, what is the error message?

0
Jtilley84
Jtilley84

2 years ago on Step 6

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

0
Ashraf Minhaj
Ashraf Minhaj

Reply 2 years ago

Thank you Bro.