nada abdelnaby mady
Published

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.

IntermediateShowcase (no instructions)1 hour4,370
Security System With 1Sheeld

Things used in this project

Hardware components

1Sheeld
1Sheeld
×1
LED (generic)
LED (generic)
×1
Arduino UNO
Arduino UNO
×1
1Sheeld
1Sheeld
×1
ultrasonic
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Hand tools and fabrication machines

smartphone

Story

Read more

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

keypad of the app

you can get from the link included in the software part

Code

arduino code

Arduino
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());
}

Credits

nada abdelnaby mady

nada abdelnaby mady

1 project • 1 follower
student at faculty of engineering communication department arduino instructor at IEEE CUSB

Comments