The Smart Garbage is a system in which it regularly checks for garbage collection and informs the concerned authority for cleaning so it won't cause any pollution . We are using HC-SR04 (UltraSonic Sensor) for checking that garbage is full or empty. An ultrasonic sensor is placed on the top level of garbage sensing the obstacle and give the output by lighting up the led and it can give the message to the Cleaning authority. An ultrasonic sensor has 4 pins [Vcc (Power), Gnd, Echo(Ultrasonic Reciever),Trigger(Ultrasonic Transmitter)].By giving high values to trigger and it emits ultrasonic wave and echo receive the wave and can be used to sense the distance by the formula of speed=distance/time. Here we are using formula (dist=dur*0.034/2) were (0.034/2) is the speed of the emission of ultrasonic waves and dur is the input of echo values.
Schematics
Concept
Coding
//Smart Garbage
int t=10;
int e=9;
void setup() {
Serial.begin(9600);
pinMode(t,OUTPUT);
pinMode(e,INPUT);
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(7,OUTPUT);
}
long dist;
long dur;
void loop() {
digitalWrite(t,LOW);
delayMicroseconds(2000);
digitalWrite(t,HIGH);
delayMicroseconds(1000);
digitalWrite(t,LOW);
dur=pulseIn(e,HIGH);
dist=dur*0.034/2;
delay(200);
Serial.print("Distance:");
Serial.println(dist);
if(dist<=4)
{ Serial.print("CallCollecector");
//delay(1000); njs
digitalWrite(7,HIGH);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
}
else
{ digitalWrite(2,LOW);
digitalWrite(3,LOW);
}
}