How to make Smart Dustbin with Arduino


Today we learn How to make Smart Dustbin with Arduino. A smart dustbin is a type of dustbin that uses technology such as sensors, microcontrollers, and internet connectivity to enhance its functionality. The primary aim of a smart dustbin is to make waste management more efficient, hygienic, and environmentally friendly. In this project, we will be using an Arduino microcontroller to create a smart dustbin that can detect when trash is deposited and automatically open and close the lid.

Hardware Required

Components#Buy From Amazon
Arduino UNO1Buy Now
HC-SR04 Ultrasonic Sensor1Buy Now
SG-90 Servo Motor1Buy Now
Dustbin1Buy Now
Battery 9v1Buy Now
Jumper WiresFewBuy Now
Breadboard1Buy Now

What is the HC-SR04 Ultrasonic Sensor?

The HC-SR04 Ultrasonic Sensor is a popular sensor module used in electronics projects to measure distances between objects. It works by emitting high-frequency sound waves that bounce off nearby objects and return to the sensor. By measuring the time it takes for the sound waves to return, the sensor can calculate the distance to the object. The HC-SR04 Ultrasonic Sensor is small, affordable, and easy to use, making it a popular choice for hobbyists and DIY enthusiasts. It can be used in a wide range of applications, including robotics, home automation, and security systems.

Pinout of HC-SR04 Sensor


Pinout Configuration of HC-SR04 Sensor

Pin NameDescription
VccThe Vcc pin powers the sensor, typically with +5V
TriggerTrigger pin is an Input pin. This pin has to be kept high for 10us to initialize measurement by sending US wave.
EchoEcho pin is an Output pin. This pin goes high for a period of time which will be equal to the time taken for the US wave to return back to the sensor.
GroundThis pin is connected to the Ground of the system.

What is SG-90 Servo Motor?

SG90 Servo Motor is a small and economical type of servo motor that is commonly used in various robotic and automation projects. It is a type of rotary actuator that provides precise control over the angular position of a device. The SG90 is a 9g micro servo motor with a torque of 1.8 kg/cm and a rotation angle of approximately 180 degrees.

SG90 Servo Pinout

Pin NamePin Description
SignalSignal or PWM pin
GNDGround Pin

Working Explanations

The smart dustbin will use an ultrasonic sensor to detect the presence of an object, in this case, trash, within a certain range. Once the sensor detects the trash, it will send a signal to the Arduino microcontroller, which will activate a servo motor to open the lid of the dustbin. After a certain period, the servo motor will close the lid of the dustbin. Additionally, the project can be enhanced by adding Wi-Fi connectivity, allowing the user to receive real-time updates on the level of trash in the bin and receive notifications when the bin needs to be emptied.

Circuit Diagram


Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Installing Libraries

Now when you are Ready to upload the code, to the Arduino Board you will need first to add the Following Libraries in Arduino, If you Learn How to add the library in the Arduino step-by-step guide click on how to install the library Button given Blow


//For more Projects:

#include <Servo.h>   //servo library
Servo servo;     
int trigPin = 5;    
int echoPin = 6;   
int servoPin = 7;
int led= 10;
long duration, dist, average;   
long aver[3];   //array for average

void setup() {       
    pinMode(trigPin, OUTPUT);  
    pinMode(echoPin, INPUT);  
    servo.write(0);         //close cap on power on

void measure() {  
digitalWrite(trigPin, LOW);
digitalWrite(trigPin, HIGH);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
dist = (duration/2) / 29.1;    //obtain distance
void loop() { 
  for (int i=0;i<=2;i++) {   //average distance
    delay(10);              //delay between measurements

if ( dist<50 ) {
//Change distance as per your need


  1. Home use: A smart dustbin can be used in households to make waste management more efficient and hygienic. The automatic lid ensures that the trash is not exposed, reducing the risk of contamination and foul odor.
  2. Public places: A smart dustbin can be installed in public places such as parks and shopping malls to encourage people to dispose of their waste properly.
  3. Hospitals: Smart dustbins can be installed in hospitals to improve hygiene and reduce the risk of infections.
  4. Smart Cities: Smart dustbins can be integrated into the larger smart city infrastructure to enhance waste management and improve the environment.
  5. Offices: Smart dustbins also using in offices to promote a cleaner and healthier work environment.


A smart dustbin is a simple yet effective example of how technology also uses to solve everyday problems. By automating the waste management process, we can reduce the risk of contamination and improve the hygiene of our surroundings. With the advent of the Internet of Things (IoT) and smart city initiatives, the potential applications of smart dustbins are limitless.

Leave a Comment