
:-by harshak the maker
you can get the video hereclick here to get the video
so guys in the video i have showed that how i made this smart dustbin using arduino
the materials used:-
arduino uno ultrasonic sensor servo motor cardboard pieces thread so these are the materials that i have used make the smart dustbin
code:-
now we have program the arduino uno
to program the arduino uno i have the code below
#include //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() { Serial.begin(9600); servo.attach(servoPin); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); servo.write(0); //close cap on power on delay(100); servo.detach(); } void measure() { digitalWrite(10,HIGH); digitalWrite(trigPin, LOW); delayMicroseconds(5); digitalWrite(trigPin, HIGH); delayMicroseconds(15); 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 measure(); aver[i]=dist; delay(10); //delay between measurements } dist=(aver[0]+aver[1]+aver[2])/3; if ( dist<50 ) { //Change distance as per your need servo.attach(servoPin); delay(1); servo.write(0); delay(3000); servo.write(150); delay(1000); servo.detach(); } Serial.print(dist); }
after you upload the program you can make the connection the connections are given below
so in this simple way we can make this smart dustbin
my other videos:-
how to make a nodemcu based home automatation
you can subscribe my youtube channel harshak the maker at:- thank you
you can clear your doubts by login on this page