Project showcase
Security System With 1Sheeld

Security System With 1Sheeld

It is a security system using 1Sheeld and its keypad, also included an ultrasonic that can detect if someone entered the home or not.

  • 2,018 views
  • 0 comments
  • 2 respects

Components and supplies

Necessary tools and machines

smartphone

About this project

Video link for the project: it describes how the project work.

Code

arduino codeArduino
first copy this code and past it into you arduino IDE then upload it on the circuit after connecting it prepare you smartphone to connect it with the shield by downloading the shield app from the link below and this link( http://1sheeld.com/ ) will help you to get start with the shield ....
/* this code is used to check if someone trying to enter you home ,after entering the password 3 times wrong using the keypad of the shield 
the shield will send you a message that 
tell you someone try to enter your home ,if he had already entered the ultrasonic will detect that
then the shield will write a post on your timeline to ask people who near from your home to help you ,cause this one nw in you home.
the led will blink only when the password is correct
the password will be (1234)*/
#define CUSTOM_SETTINGS
#define INCLUDE_SMS_SHIELD
#define INCLUDE_FACEBOOK_SHIELD
#define INCLUDE_KEYPAD_SHIELD
#define INCLUDE_TERMINAL_SHIELD
#include <OneSheeld.h>
#define ECHOPIN 12       // Pin to receive echo pulse 
#define TRIGPIN 11      // Pin to send trigger pulse

/* Define an iterator. */
int iterations = 0;

bool isAnyButtonIsPressed = false;

/* A name for the LED on pin 13. */
int ledPin = 5;
int i = 0;

void setup()
{
  /* Start communication. */
  OneSheeld.begin();
  /* Set the LED as output. */
  pinMode(ledPin, OUTPUT);
  pinMode(ECHOPIN, INPUT);
  pinMode(TRIGPIN, OUTPUT);
}

void loop()
{
  /* Check if any button is pressed */
  if ((Keypad.isAnyColumnPressed() || Keypad.isAnyColumnPressed()))
  {
    isAnyButtonIsPressed = true;
    Terminal.println("A button is pressed");
  }
  else {
    isAnyButtonIsPressed = false;
  }

  /* Check if "1" is pressed, iterate one time. */
  if (iterations == 0 && isOnePressed() && isAnyButtonIsPressed == true)
  {
    Terminal.println("One is pressed");
    iterations++;
  }
  /* Check if "2" is pressed, iterate one time. */
  else if (iterations == 1 && isTwoPressed() && isAnyButtonIsPressed == true)
  {
    Terminal.println("Two is pressed");
    iterations++;
  }
  /* Check if "3" is pressed, iterate one time. */
  else if (iterations == 2 && isThreePressed() && isAnyButtonIsPressed == true)
  {
    Terminal.println("Three is pressed");
    iterations++;
  }
  /* Check if "4" is pressed, iterate one time. */
  else if (iterations == 3 && isFourPressed() && isAnyButtonIsPressed == true)
  {
    Terminal.println("Four is pressed");
    iterations++;
  }
  /* Check if any other button is pressed, reset iterations. */
  else if (isOtherButtonPressed() && isAnyButtonIsPressed == true)
  {
    iterations = 0;
  }

  //--------------------------------- Check out the password --------------------------------------
  /* Check if the number of iterations is 4, blink the LED. */
  if (iterations == 4)
  {
    digitalWrite(ledPin, HIGH);
    OneSheeld.delay(3000);
    digitalWrite(ledPin, LOW);
    OneSheeld.delay(3000);
    Terminal.print("Welcome home");
    /* Reset the iterator. */
    iterations = 0;
    isAnyButtonIsPressed == false;
  }
  else if (iterations == 0 && isAnyButtonIsPressed == true) {
    Terminal.println("Wrong one try again ");
    i += 1;
    Terminal.print("Number of trials = ");
    Terminal.println(i);

    if (i == 3) {
      Terminal.println("The third wrong trial");

      /* Send the SMS. */
      SMS.send("write your mobile number", "someone trying to enter my house");
      Terminal.println("SMS was sent");
      // read the ultrasonic value 10 times
      for (int j = 0; j <= 9; j++) {
        readUltrasonic();
      }
      // reset the values of i
      i = 0;

    }//if i equal 3
  }//void loop

  delay(150);
}//void loop

void readUltrasonic() {
  //--------------------------------- Check out ultrasonic sensor --------------------------------------
  /* ultrasonic code to check if someone has entered the house */
  digitalWrite(TRIGPIN, LOW);
  delayMicroseconds(2);
  digitalWrite(TRIGPIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIGPIN, LOW);

  // Distance Calculation
  float distance = pulseIn(ECHOPIN, HIGH);
  distance = distance / 58;
  Terminal.print(distance);
  Terminal.println(" cm");

  if (distance < 50) {
    Facebook.post("heeelp! someone has entered my home ..");
  }
  else {
    Terminal.println("safe");
  }
}

//--------------------------------------- Keypad Functions ---------------------------------------
/* Helper functions check if a certain button is pressed by checking its row and column. */
boolean isOnePressed() {
  return Keypad.isRowPressed(0) && Keypad.isColumnPressed(0);
}

boolean isTwoPressed() {
  return Keypad.isRowPressed(0) && Keypad.isColumnPressed(1);
}

boolean isThreePressed() {
  return Keypad.isRowPressed(0) && Keypad.isColumnPressed(2);
}

boolean isFourPressed() {
  return Keypad.isRowPressed(1) && Keypad.isColumnPressed(0);
}

boolean isOtherButtonPressed() {
  return ((Keypad.isAnyColumnPressed() || Keypad.isAnyColumnPressed()) && !isOnePressed() && !isTwoPressed() && !isThreePressed() && !isFourPressed());
}

Schematics

project hardware
first we will connect 1sheeld with arduino as the image show then connect the ultrasonic and the led with pins 11,12,5 of the shield and make a common vcc and ground
Img 20160218 231653
keypad of the app
you can get from the link included in the software part
1sheeld example lock

Comments

Similar projects you might like

Smart Home Automation And Security System Using 1Sheeld

Project tutorial by SADEE

  • 8,843 views
  • 6 comments
  • 31 respects

Home Security Automation Using 1Sheeld

Project showcase by Ahmed Ismail and Hussien Mohamed

  • 4,302 views
  • 0 comments
  • 6 respects

Ultrasonic Security System

Project tutorial by Ivan

  • 34,861 views
  • 23 comments
  • 80 respects

Security System Using Arduino Bluetooth Camera

Project tutorial by amrmostaafaa

  • 13,222 views
  • 12 comments
  • 28 respects

Thief Trap security system

Project tutorial by Ahmed Abd El Rahman

  • 3,564 views
  • 0 comments
  • 6 respects

Security System And Access Control With Arduino And RFID

Project tutorial by Sarath P

  • 10,279 views
  • 1 comment
  • 22 respects
Add projectSign up / Login