Ahmed Abd El Rahman
Published © CC BY-NC-SA

Thief Trap security system

This system will detect if a thief enters my home, and then a mechanism will lock the doors to prevent him from getting out

IntermediateFull instructions provided8,147

Things used in this project

Story

Read more

Schematics

thief trap security system

Code

Untitled file

Arduino
/*this code will make the led on and will make the servo rotate 180 degree to close the door after 
the theif enter when the motion sensor feel that someone enter and send SMS to the phone number of the 
owner telling him that the theif eneterd the house */

       //include 1sheeld and servo motor libraries
#include <OneSheeld.h>
#include <Servo.h>
         //create servo object to control a servo
Servo myservo;
       //define a boolean flag
boolean isMessageSent = false;
          //define constants that  will not change 
const int sensorPin=7;
const int ledPin=13;
      //variable for reading the PIR(motion sensor) value
int sensorState=0;

//*************************8SETUP*****************************

void setup(){
	//start comunication
	OneSheeld.begin(); 
//initialize ledpin as output
  pinMode(ledPin,OUTPUT);
     //initialize sensorpin as input
  pinMode(sensorPin,INPUT);
   //attach servo to pin 9
  myservo.attach (9);
  
}

//**************************LOOP*******************************

void loop(){
	  // read the state of the sensor value:
  sensorState=digitalRead(sensorPin);
  //always check that the sensor state is high
  if (sensorState==HIGH){{
    if(!isMessageSent)
    //send the massage
     SMS.send("0123456789","there is a thief in the house");
     //turn the led on
     digitalWrite(ledPin, HIGH);
     //rotate the servo 180 degree
       myservo.write(180);
  delay(10000);
  //after 10 seconds rotate the servo 0 degrees 
           myservo.write(0);

  }
}
  else{
  	//set the flag 
     isMessageSent = false;
     //turn the led off
     digitalWrite(ledPin, LOW);

  }

}

thief trap security system

Credits

Ahmed Abd El Rahman

Ahmed Abd El Rahman

1 project • 0 followers

Comments