Smart Dustbin using Arduino and Ultrasonic Sensor

Published  February 28, 2022   0
N Naveed Zahid Hussain
Arduino Smart Dustbin using Ultrasonic Sensor

Smart Dustbin as its name represents its work smartly or we can say that it is an automatic dustbin. Smart Dustbin is a very good project from the Arduino. We can say that It is a decent gadget to make your home clean and attractive. kids spread trash to a great extent by paper, rappers and numerous different things at home. They will have fun with this dustbin they play with the dustbin and in the play of them, they clean your home as well because every time they use the smart Dustbin and it attracts the kids. They generally will be utilized to throw all trash and waste into this smart dustbin. if your hands are full of trash or junk and you're unable to open it manually this can be used. As it opens automatically without touching, this can help to control the spread of Coronavirus and even mosquitoes will not move around it so that it helps from preventing the spread of new diseases. 

Previously, We have also built IoT Based Dumpster Monitoring using ESP8266 and IoT Smart Dustbin using NodeMCU.

Component Requirement for Arduino Based Dustbin

Smart Dustbin Components

Project Used Hardware

  • Arduino UNO,
  • Jumper Wires,
  • Servo Motor,
  • Ultrasonic Sensor

Project Used Software

  • Arduino IDE

Project Hardware Software Selection

Arduino UNO: As you know that Arduino is a microcontroller-based open source electronic prototyping board that can be programmed with an easy-to-use Arduino IDE. The UNO is one of the most popular boards in Arduino family and a great choice for beginners.

Ultrasonic Sensor: These are the sensor that use ultrasonic waves to detect objects or to measure the distance between themselves and the object

Servo Motor: This is an electrical device that can push or pull and also rotate an object with great precision. if you want to rotate an object at some specific angles or distance, then you use servo motor. It is made up of a simple motor that runs through a servo mechanism. We can get a very high torque servo motor in a small and light weight packages.

Circuit Diagram


Smart Dustbin using Arduino and Ultrasonic Sensor Circuit Diagram

#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

Have any question realated to this Article?

Ask Our Community Members