Smart Waste Bin

Description   
  
     In this innovative world, everything getting smarter. So why not your waste bin? This waste bin opens automatically when someone comes in front to dump waste. after a certain delay, it will close automatically. If it opens it gives the green light and if it closes it gives red light. And it gives a sound when it opens.

For more details contact us. 

Components Required

 1. Arduino UNO      1
 2. Ultrasonic Sensor(HC-SR04)   1
 3. Servomotor    1
 4. LED(Green)     1 
 5. LED(Red)   1
 6. Buzzer           1
 7. Jumper Wires      1

Circuit Diagram

Program
#define trigPin 8
#define echoPin 7 
#include <Servo.h>
Servo servosweep;  
float pos = 0.0;

 void setup() 
{
 servosweep.attach(9);  
Serial.begin (9600); 
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
}
void loop() 
{ 
long duration, distance; 
digitalWrite(trigPin, LOW); 
delayMicroseconds(2); 
digitalWrite(trigPin, HIGH); 
delayMicroseconds(10); 
digitalWrite(trigPin, LOW); 
duration = pulseIn(echoPin, HIGH); 
distance = (duration/2) / 29.1; 
Serial.print(distance); 
Serial.println(" cm"); 
delay(200);
  
if (distance < 30) 
{ 
   servosweep.write(150);
   delay(20);         
  }

if (distance > 30) 
{ 
   servosweep.write(0);
   delay(20);         
}  
}