Smart Dustbin with Arduino

A dustbin with Smart Feature

Smart Dustbin is one of the most popular projects from the Arduino Nowadays. Even students from the school, colleges also trying to make this awesome smart dustbin projects. the smart dustbin with Arduino is a simple project with the least required components. you need to require a distance measuring device, processing unit and output device for movement in the lid of the Dustbin. here we will show you how to combine all these devices together to make the system working. we will discuss on the circuit diagram and code also. and the working of all devices also. if you looking for more electronic projects so you can find the other electronics and Arduino projects here.

Working of the smart dustbin is easy to understand. you have to be near to the smart dustbin on a particular distance. for example, is the particular distance in the code is 25 centimeters so you have to be near than this range. we can customize the distance as our requirement. in the smart dustbin with Arduino, you can use an ultrasonic sensor which can measure the distance of the object in front of it. when a person will come in front of the dustbin and he will be in the range of the distance which we have mentioned in the code. then ultrasonic send some data to the Arduino and Arduino will process on that data to send the instruction.

Components required for Smart dustbin with Arduino

  • Ultrasonic sensor HC-SR04
  • Arduino Uno
  • Servo motor
  • Wires
  • Dustbin

Ultrasonic sensor HC-SR04:- 

Ultrasonic sensor work on the ultrasonic frequency. a sensor having the two parts. one is transmitter and other is a receiver. transmitter transmit the ultrasonic wave and it gets back after targeting any object. we calculate the distance by the speed formula. time duration takes by the ultrasonic sensor to target and back to the receiver give the distance from the object.

Servo Motor

Servo motor is used to move the lid part of the dustbin. when the ultrasonic detect any person in front of the dustbin then Arduino sends the command to the servo motor and servo motor help rotate to give the movement to the lid. the servo motor is a negative feedback motor which knows the angle and speed due to its ic.

Arduino Microcontroller

Arduino is an Open source AVR based board which also known as a microcontroller. it has 3 port and 14 gpio pins 6 analog pins.

Circuit Diagram for Smart dustbin with Arduino

Code for Smart dustbin with Arduino 

#include <Servo.h>

Servo servoMain; // Define our Servo

int trigpin = 10;

int echopin = 11;

int distance;

float duration;

float cm;

void setup()


servoMain.attach(9); // servo on digital pin 10

pinMode(trigpin, OUTPUT);

pinMode(echopin, INPUT);


void loop()


digitalWrite(trigpin, LOW);


digitalWrite(trigpin, HIGH);


digitalWrite(trigpin, LOW);

duration = pulseIn(echopin, HIGH);

cm = (duration/58.82);

distance = cm;



servoMain.write(180); // Turn Servo back to center position (90 degrees)








Upload the given code into your Arduino and assemble the setup for Smart dustbin. Thanks

What do you think?

1 point
Upvote Downvote

Written by shahid

Film in the Past

WiFi RGB Mood Light