Smart dustbin

TLMXB001

To participate in Swatchh Bharat Abhiyan, Jugaadu identified a small problem to solve. Many times he realized that people do not open the lid of the dustbin and throw stuff on or around it.
Digital and Networking Kit
  1. Place the US sensors in front of the dustbin.
  2. Connect US module with Arduino, switch, battery and servo motor using connecting wires on bread-board.
  3. Program the Arduino and upload the sketch Using A to B USB Cable.
  4. Test it by power it on.

    

#include <Servo.h>

Servo servo1;

int trigPin = 4;

int echoPin = 5;

long distance;

long duration;

int pos=0;

void setup() 

{

servo1.attach(9); 

 pinMode(trigPin, OUTPUT);

 pinMode(echoPin, INPUT);

 Serial.begin(9600);

}

 void loop() {

ultra();

servo1.write(0);

if(distance <= 10){

servo1.write(90);

delay(4000);

}

}

 void ultra(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = duration*0.034/2;

Serial.println(distance);

}