top of page

Smart Dustbin using Arduino

Heading 1

Businesswomen Walking in Hallway

In this project, I will show you How to Make a Smart Dustbin using Arduino, where the Cap of the dustbin will automatically open when you approach with trash. The other important components used to make this Smart Dustbin are an HC-04 Ultrasonic Sensor and an Servo Motor.


Components:

1. Ultrasonic Sensor

2. Arduino

3. Servo Moter S9

4. Jumper Wire

5. Switch

6. Battery

7. Battery Clipper


Working:

After setting up the Smart Dustbin and making all the necessary connections, upload the code to Arduino and provide 5V power supply to the circuit. Once the system is powered ON, Arduino keeps monitoring for any object near the Ultrasonic Sensor.

If the Ultrasonic Sensor detects any object like a hand for example, Arduino calculates its distance and if it less than a certain predefined value, Arduino will activate the Servo Motor and with the support of the extended arm, it will list the lid open.

After certain time, the lid is automatically closed.


Code:

#include <Servo.h>

Servo myservo;  

int pos = 20;  

const int trigPin = 5;

const int echoPin = 6;

const int led = 13; 

long duration;

float distance; 

void setup() 

{  

myservo.attach(11); 

pinMode(trigPin, OUTPUT); 

pinMode(echoPin, INPUT);  

pinMode(led, OUTPUT);  

myservo.write(pos);

void loop() 

//Serial.begin(9600); 

digitalWrite(trigPin, LOW); 

delayMicroseconds(2); 

digitalWrite(trigPin, HIGH); 

delayMicroseconds(10); 

digitalWrite(trigPin, LOW);   

duration = pulseIn(echoPin, HIGH);  

distance = 0.034*(duration/2); 

//Serial.println(distance); 

if (distance < 27)  

digitalWrite(led,HIGH);    

myservo.write(pos+160);

 delay(1000);  

}

 else   

digitalWrite(led,LOW);      

myservo.write(pos); 

 } 

delay(300);

}

view rawArduino_Dustbin.ino hosted with ❤ by GitHub


Conclusion:

A simple but useful project called Smart Dustbin using Arduino is designed and developed here. Using this project, the cap of the dustbin stays closed, so that waste is not exposed and when you want dispose any waste, it will automatically open the cap.

bottom of page