PIR Sensor Security

Have you ever wanted to have some way to protect your room, now you can. This is an easy project that can be easily built. It shoots pencils, pens, and much more.

What I made: It is simply a servo activated crossbow. IT is made of a motor, some wood, Arduino, rubber bands, and a PIR sensor. It uses a servo to set it off. It shoots cylindrical objects.

How I made it: I build this using pieces of wood found around the house and electronic parts I already had. I used hot glue and screws to hold it together. I worked by myself. I first thought of doing it out of Lego Technic parts, but thought that wood would be stronger.

Where I made this: I made this at my house spending some of my time in my room.

What I learned: I learned that Arduino can be good for many things, I also learned about passive sensors, and how simple parts can be powerful.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1:

Step 2: Crossbow Parts

You will need • 6 by 6 in piece of 1 inch thick wood • 6 by 3/4 inch by 3/4 inch • rubber bands • 2 screws

Step 3: Attach Small Piece to Large Piece

Take the small piece and put it on the edge to the large. Drill two pilot holes about 1 cm from the edge. Place the screws into holes and tighten. Drill a hole in the center of the small piece the size of a pencil

Step 4: Attach Rubber Bands

Take the rubber bands and tie through the two holes creating a loop

Step 5: Mounting the Servo

Glue the servo in to place making the moving part a little to the right of the hole in the center

Step 6: Wiring

Place the PIR sensor in the ground, pin13, and pin12 holes The servo wiring is red wire to 5v, white wire to pin12, and black to ground

Step 7: Mount Electronics

You can do it anyway way you want but I simply glued it to the wood.

Step 8: Code

#include <Servo.h>

Servo myservo;

int pos = 0;

int calibrationTime = 30;       

long unsigned int lowIn;        

long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int pirPin = 12;
int pirPos = 13;

void setup(){
  myservo.attach(4);
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(pirPos, OUTPUT);
  digitalWrite(pirPos, HIGH);

  Serial.println("calibrating sensor ");
  for(int i = 0; i < calibrationTime; i++){
    Serial.print(calibrationTime - i);
    Serial.print("-");
    delay(1000);
  }
  Serial.println();
  Serial.println("done");
  while (digitalRead(pirPin) == HIGH) {
    delay(500);
    Serial.print(".");     
  }
  Serial.print("SENSOR ACTIVE");
  delay(1000);
}

void loop(){

  if(digitalRead(pirPin) == HIGH){
    for(pos = 0; pos < 180; pos += 1)
    {
      myservo.write(pos);
      delay(5);
    }
    for(pos = 180; pos>=1; pos-=1)
    {                               
      myservo.write(pos);
      delay(5);
    }
    if(lockLow){ 

      lockLow = false;           
      Serial.println("---");
      Serial.print("motion detected at ");
      Serial.print(millis()/1000);
      Serial.println(" sec");
      delay(50);
    }        
    takeLowTime = true;
  }

  if(digitalRead(pirPin) == LOW){      

    if(takeLowTime){
      lowIn = millis();
      takeLowTime = false;
    }

    if(!lockLow && millis() - lowIn > pause){ 

      lockLow = true;                       
      Serial.print("motion ended at ");
      Serial.print((millis() - pause)/1000);
      Serial.println(" sec");
      delay(50);
    }
  }
}

Make-to-Learn Youth Contest

Participated in the
Make-to-Learn Youth Contest

UP! Contest

Participated in the
UP! Contest

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    4 Discussions

    None
    ddug

    5 years ago on Introduction

    please upload a video for this project.....