close

In this project we will see how the barrier is opened and closed when the human passes in front of the PIR sensor. When human comes in front of PIR sensor the barrier will be opened automatically and closed after 5 seconds.

This program is used to open the barrier. When there is a human movement in front of pir sensor,the output of pir sensor goes to high and the servo motor will be activated by 90 degree speedly and the red led will be off and green led will be on. After some time (4 second), it will come back to 0 degree slowly slowly and red led will be on and green led will be off. Also the detection range from 3 meter to 7 meter.

We have seen at some shopping malls and some offices, when any human comes near the gate the barrier or the gate opens automatically. And it closes if there is no movement. Using this technology we can reduce the man power to open or close the barrier or gate while human movement. In case of air condition hall, the gate is automatically open at human movement and close at no movement. So it reduces the cold air from passing out from the hall. So it may reduce the electricity load of an air condition. Thus we can save the electricity and human power. Hope you will understand this detail.

The material used in this project:

  1. Arduino uno
  2. USB cable for Arduino board power
  3. Arduino shield for dc motor, stepper motor and servo motor
  4. 5V 2A Power Supply for shield board power
  5. servo motor
  6. PIR sensor
  7. Green LED (5 mm) 1
  8. Red LED (5 mm) 1
  9. Resistor 330 ohm 2
  10. Female to Female Jumpers 10 pc
  11. Straw Pipe for barrier
Model Working
#include <Servo.h>
Servo myservo;      // create servo object to control a servo
int pos = 0;        // variable to store the servo position
const int red = A3; //define red led
const int grn = A2; //define green led
const int pir = A0; //pir sensor is sonnected at pin A0
int val = 0;        // variable to store the sensor status (value)
void setup()
{
  pinMode(pir,INPUT); //pir output pin is connected to A0 pin of an Arduino
  pinMode(red, OUTPUT); 
  pinMode(grn, OUTPUT);
  
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  digitalWrite(red, HIGH); // turn the LED on 
  digitalWrite(grn, LOW); // turn the LED off 
  
  for (pos = 90; pos >= 0; pos -= 1)// goes from 90 degrees to 0 degrees
  { 
      myservo.write(pos);   // tell servo to go to position in variable 'pos'
     
      delay(20);            // waits 20ms for the servo to reach the position
  }
  
}
void loop() 
{
  
  val = digitalRead(pir);       // read sensor value
   
  if (val == HIGH)              // check if the sensor is HIGH 
  {
    for (pos = 0; pos <= 90; pos += 1) 
    {
        // goes from 0 degrees to 90 degrees in steps of 1 degree
      myservo.write(pos);   // tell servo to go to position in variable 'pos'
    
      delay(5);             // waits 5ms for the servo to reach the position
    }
    digitalWrite(red, LOW); // turn the LED off 
    
    digitalWrite(grn, HIGH); // turn the LED on    
    
    delay(4000);            //wait for 4000ms
    
    digitalWrite(red, HIGH); // turn the LED on 
    
    digitalWrite(grn, LOW); // turn the LED off 
     
    for (pos = 90; pos >= 0; pos -= 1)  // goes from 90 degrees to 0 degrees 
    {  
      myservo.write(pos);   // tell servo to go to position in variable 'pos'
      
      delay(20);            // waits 15ms for the servo to reach the position
    
    }
  }
}
admin

The author admin

Leave a Response

WhatsApp chat