Your Cart

Automatic Dustbin using Arduino

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.

Dustbin Project using Arduino How to DIY

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.

Dustbin Project using Arduino How 1

Components Used:-


Arduino Uno

Ultrasonic sensor


Green LED

Servo Motor (995G)

Jumper wires

Hook-up wire



  1. 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.
  2. Place an ultrasonic sensor at the front of the dustbin so that any person coming in front of the dustbin easily can be detected.
  3. Place another sensor inside the dustbin in this manner so that it can easily detect the rubbish inside the dustbin.
  4. You can place the Arduino wherever you are comfortable according to the wiring.
  5. You can attach a 5v battery to it, we have used a power supply of 5v.


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.

Dustbin Project using Arduino Ho it works

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 :-

Circiut Diagram for Dustbin Project using Arduino How to DIY


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()



pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(trigPin1, OUTPUT);

pinMode(echoPin1, INPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);



void loop()


digitalWrite(trigPin, LOW);


digitalWrite(trigPin, HIGH);


digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distanceCm= duration*0.034/2;

distanceInch = duration*0.0133/2;


digitalWrite(trigPin1, LOW);


digitalWrite(trigPin1, HIGH);


digitalWrite(trigPin1, LOW);

duration1 = pulseIn(echoPin1, HIGH);

distanceCm1= duration1*0.034/2;

distanceInch1 = duration1*0.0133/2;

Serial.print(“Distance: “);


Serial.print(”    “);

Serial.print(“Distance: “);



if (distanceCm<20)


myservo.write(80);              // tell servo to go to position in variable ‘pos’





myservo.write(0);              // tell servo to go to position in variable ‘pos’



if (distanceCm1<10)


digitalWrite(10, HIGH);

digitalWrite(11, LOW);




digitalWrite(10, LOW);

digitalWrite(11, HIGH);



We have given all the required steps and content.  Good luck!

Check out our other projects:

To learn about The Best Arduino Starter Kits from Kunkune Click Here!