Overview
This project deals with a very common problem faced by our society daily. The problem with opening the dustbins, with the help of these Automatic Dustbins you don’t have to touch the dustbins you just have to go near the dustbins the dustbins will get open by themselves after sensing you near them.
In this project we have used a PIR Sensor and a Servo Motor here the sensor senses the person near it and tells the motor to rotate and open the dustbin so that the user can throw the waste in the dustbin without touching it.
Hardware required
- Arduino Uno R3
- PIR Sensor
- Micro Servo Motor
- BreadBoard
- Jumper Wires
Schematic Diagram
Fig 1. Circuit Diagram
Arduino Code :
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
int inputPin = 12; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup() {
myservo.attach(4); // attaches the servo on pin 4 to the servo object
pinMode(inputPin, INPUT);
Serial.begin(9600);
}
void loop() {
val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
if (pirState == LOW) {
myservo.write(0); // tell servo to go to position in variable '0'
delay(1500); // waits 1500ms for the servo to reach the position
pirState = HIGH;
}
}
else {
if (pirState == HIGH){
myservo.write(180); // tell servo to go to position in variable '180'
delay(1500);
pirState = LOW;
}
}
}
Precautions
- Connections should be done properly.
- Arduino is case Sensitive so code accordingly.
- Give different colors to the wires.