Hey Techies.
Today we are sharing a very cool project. We are making an Automatic dustbin, which is smart in its ways. Like when you come near the dustbin it will automatically open the lid. Which can help you a lot to reduce the risk of spreading disease.
Also, we have added one more function to it. That is an overflow alarm. Which works for rubbish. If there is no space inside the dustbin will make an alarm noise. This is really a very interesting project that you can use anywhere like school, home, and offices. Only it needs a very small amount of electricity to operate this dustbin.
In case you can use both the things like battery and power supply. We are going to give you all the information only if you have read and follow the given steps. So, let’s get started.
Introduction to the Arduino based dustbin
This is our smart dustbin project which is very popular nowadays. It is very simple to make, only we need some electronic components to make it. We will share full details of the project such as code, circuit diagram and step by step construction. So, with the help of these components, we will make this automatic dustbin which automatically opens the lid when you come in front of the sensor. Also, there is an overflow alarm inside the dustbin so, when it is full and you are at the front of the dustbin. The dustbin will not open the lid. Instead of opening the lid it will start an alarm that there is no space inside the dustbin. You have to first clear the rubbish from the dustbin.
Components Used:-
Ultrasonic sensor
Red LED
Green LED
Servo Motor (995G)
Hook-up wire
Buzzer
Constructions:-
- Connect the servo motor with the dustbin lid in this manner so that when the servo motor rotates the 90 degree lid will open and when the servo motor rotates in reverse the lid will close. You can paste the servo motor with the glue gun.
- Place an ultrasonic sensor at the front of the dustbin so that any person coming in front of the dustbin easily can be detected.
- Place another sensor inside the dustbin in this manner so that it can easily detect the rubbish inside the dustbin.
- You can place the Arduino wherever you are comfortable according to the wiring.
- You can attach a 5v battery to it, we have used a power supply of 5v.
Working:
In the behalf of the working of this dustbin, we can divide the working in two parts.
1st Setup Working of opening the lid :-
Whenever someone comes in front of the sensor, the ultrasonic sensor senses the object and sends this information to the Arduino and the Arduino compares this value to the threshold value which we have entered into the code. The threshold value for the lid we have adjusted is 20 centimetres. It depends on you whatever distance you need. So, when the sensor value crosses the threshold value, then the Arduino sends the commands to the servo motor to be rotated 90 degrees. And after 10 seconds, the servo motor will rotate reverse. This is how the system works for 1st setup. Now we will talk about the 2nd setup.
2nd Setup working , overflow alarm:-
The ultrasonic sensor continuously checks the dustbin from the inside. When the rubbish inside the dustbin is full, then the ultrasonic sensor sends this information to the Arduino that the dustbin is full. In reaction to this situation, the Arduino will send the instruction to start the buzzer and the red light. So, when we empty the bin, the buzzer will stop and the red LED will turn off and the green LED will turn on. So, this is how the dustbin 2nd setup works.
Circuit Diagram :-
Code:-
const int trigPin = 2;
const int echoPin = 3;
const int trigPin1 = 5;
const int echoPin1 = 4;
long duration;
int distanceCm, distanceInch;
long duration1;
int distanceCm1, distanceInch1;
#include <Servo.h>
Servo myservo;
void setup()
{
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
myservo.attach(9);
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;
delay(300);
digitalWrite(trigPin1, LOW);
delayMicroseconds(2);
digitalWrite(trigPin1, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distanceCm1= duration1*0.034/2;
distanceInch1 = duration1*0.0133/2;
Serial.print(“Distance: “);
Serial.print(distanceCm1);
Serial.print(” “);
Serial.print(“Distance: “);
Serial.println(distanceCm);
delay(300);
if (distanceCm<20)
{
myservo.write(80); // tell servo to go to position in variable ‘pos’
delay(300);
}
else
{
myservo.write(0); // tell servo to go to position in variable ‘pos’
delay(50);
}
if (distanceCm1<10)
{
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
}
else
{
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
}
}
We have given all the required steps and content. Good luck!
Check out our other projects:
- Bluetooth Notice Board Using Arduino And HC05
- Automatic Street Light using Light Sensor
- Automatic Dustbin using Arduino
- Fire Alarm Using Arduino
To learn about The Best Arduino Starter Kits from Kunkune Click Here!