✦Step 1:-Take a dustbin
✦Step 2:-make a lead such that it will be fixed from a point and open from one point
Step 3:-Then make 2 holes in the face of the dustbin for ultrasonic sensor
✦Step 4:-then fix the survo with hot glue
✦Step 5:--do wireing using the circuit diagram
✦Step 6:-code the arudino
#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);
delay(2);
digitalWrite(trigpin, HIGH);
delayMicroseconds(10);
digitalWrite(trigpin, LOW);
duration = pulseIn(echopin, HIGH);
cm = (duration/58.82);
distance = cm;
if(distance<30)
{
servoMain.write(180); // Turn Servo back to center position (90 degrees)
delay(3000);
}
else{
servoMain.write(0);
delay(50);
}
}
Copt this above code into the Arduino IDE and upload it to the Arduino. now make all connection
Now your dustbin is ready now. Thanks again for taking the time to read project.
Here is a video for watching :D