Smart Dustbin using Arduino

Smart Dustbin using Arduino

Hello Internet people, In this project I will show you how to make a smart dustbin using Arduino Uno.

This smart Dustbin have a HC-04 ultrasonic sensor and a servo motor connected with the dustbin lid. The lid of the dustbin will automatically open when you approach with trash.

For making this device we have need these components

Required components

  1. Arduino Uno
  2. Servo Motor
  3. HC-04 Ultrasonic Sensor
  4. jumper wire
  5. Red led
  6. Plastic dustbin


An Arduino is a micro-controller device or an open source platform that is able to read inputs from sensors, buttons, lights and turn it into an output for activating a motor, turning on an LED, turning on bulbsending messages. You can tell your board what to do by sending an instructions to the microcontroller on the board.

arduino uno
Arduino Uno

Servo Motor

In this Project we use a Micro servo 9g. A servo motor is an electrical device which can use for push or rotate an objects. The servo motor rotate at some specific angles or distance, it is just made by simple motor which is run through servo mechanism. servo motor have three wires in which two will be used for Supply (positive and negative) and one will be used for the signal that is to be sent from the MCU.

Servo Motor

Ultrasonic sensor

we use an ultrasonic sensor. An ultrasonic sensor is an electronic device that is use to measure distance by using ultrasonic waves. These waves are not hear by humans.

Ultrasonic Sensor

An ultrasonic sensor emit sound pulse and receiver receive echo signal that are reflected back by an obstacle (shown in figure).

working of ultrasonic sensor

Lets start the making this project

for making this project first connect the components as shown in figure

wiring diagram ultrasonic range finder
wiring diagram| image credit-google

First,take ultrasonic Sensor to Connect it With Arduino Uno

VCC – 5V

Trig – pin 6

Echo – pic 5

Gnd – Gnd

Now take the servo motor and the positive wire connect to the 5v , negative wire connect to the ground and signal wire are connect to the pin 11 in arduino.

i am use a red led for indication you may also use, connect led anode terminal in pin 13 and cathode to ground.

after that, Now stick or fix the ultrasonic sensor on the dustbin as shown in figure.

Place the sensor

Now fix the servo motor on dustbin lid, for this i’m using cardboard lid so i am cut this piece in half, stick with tape and attach a thread with cardboard and servo motor (show in figure)

servo-motor on dustbin lid
servo-Motor on lid
smart dustbin

Now open the arduino Ide and paste this code:

//smart dustbin by Anurag kumar
#include <Servo.h>
Servo myservo;  
int pos = 20;  
const int trigPin = 6;
const int echoPin = 5;
const int led = 13;

long duration;
float distance;

void setup() 
  myservo.attach(11);// attache servo motor signal wire in pin11
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT); 
  pinMode(led, OUTPUT);

void loop() 
  digitalWrite(trigPin, LOW);
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);
  distance = 0.034*(duration/2);
  if (distance < 27)

upload the code, now your smart dustbin in ready for use

smart Dustbin

Leave a Reply

Your email address will not be published. Required fields are marked *