Project tutorial
My Motion Activated Security Cam project

My Motion Activated Security Cam project © LGPL

This project will capture an image and upload it to twitter when motion is sensed!

  • 12,971 views
  • 11 comments
  • 14 respects

Components and supplies

Apps and online services

About this project

This tutorial will show you how to make a motion-activated Camera. You can use this as a security camera, or as a party cam that takes pictures when there is motion. The pictures will be uploaded to twitter as an example and you will receive an SMS when something happens, so that you can check your account.

What do you need?

**MAKE SURE THAT YOU HAVE INSTALLED ALL THE 1SHEELD LIBRARIES**

Steps for creating this motion-activated camera:

Step 1

  • Connect your 1Sheeld to your Arduino
  • Connect the Arduino to your PC
  • Make sure the 1Sheeld's UART switch is open – otherwise the Compiler will give an      error.
  • Upload this code to the Arduino: 

http://codepad.org/ckMD0prd

  • Edit the number to SMS yourself

Step 2 (The LED)

  • Connect the led to pin number 8 and, with the resistor, to ground.

Step 3 (The PIR Motion sensor)

  • When you point the PIR motion sensor bubble away from you, to see the back with      the 3 connector pins at the bottom, connect it like the following:
  • The left pin needs to connect to pin number 2,
  • The middle pin needs to be connected to 3.3V,
  • The right pin needs to be connected to ground on your Arduino.

FRITZING:

Step 4 (Connecting)

  • Pair your Android device to your 1sheeld, via the 1Sheeld app, through Bluetooth
  • Select the following shields:
  • Camera shield 
  • Twitter shield (or the Facebook shield, if you want to use Facebook. Use this code: Facebook.postLastPicture("HappyHolidays")
  • Text to speech shield, if you want
  • SMS shield, to be notified when something happens
  • Make sure that you are logged into all your accounts and that everything is authorized. Make a secondary Twitter account for your code.

Step 5 (Ready to go)

  • Make sure the code is uploaded, and wait for the LED to switch off.
  • Switch the UART switch to closed, to begin communication between the 1sheeld and your phone.
  • Check your Twitter account to look at the picture taken.

NOTE : Make a secondary Twitter account, and with your primary one FAVORITE the secondary one, to get notifications when something happens. When the security camera captures something and uploads it, you'll be notified. Or, use your primary account and get an SMS notification when something happens.

Code

Motion Activated Security Camera CODEJava
Add to Arduino IDE and UPLOAD to 1Sheeld and make sure that on the 1Sheeld the UART switch is switched to the off position.
//Need to include the following to avoid memory overload:
#define INCLUDE_SMS_SHIELD //sms
#define CUSTOM_SETTINGS
#define INCLUDE_CAMERA_SHIELD //camera
#define INCLUDE_TEXT_TO_SPEECH_SHIELD //text to speech
#define INCLUDE_FACEBOOK_SHIELD //facebook
#define INCLUDE_TWITTER_SHIELD //twitter

#include <OneSheeld.h> 
int ledPin = 8;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int PIR = LOW;             //The motionsensor's value
int val = 0;  


void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare reading sensor as input, this is the part on the Motions sensor that find the difference between no movement and movement
   OneSheeld.begin(); // Begin the onesheeld code

 
}

void loop(){
  //loop begins
    val = digitalRead(inputPin);  // read input value of the movement dectetion pin
  if (val == HIGH) {            // check if the is movement
    digitalWrite(ledPin, HIGH);  // turn LED ON  to indicate movement was found  
    delay(100); //Delays the loop for 1/10 second

    
    if (PIR == LOW) { //if the PIR value is equal to LOW do the following:
       SMS.send("0123456789","Motion DETECTED , Check Twitter for image"); //ADD your NUMBER INSTEAD OF 0123456789 , EDIT YOUR OWN
       PIR = HIGH; //Set PIR to HIGH and NOT LOW sothat it wount do a infinite loop
       TextToSpeech.say("got you"); //phone speaks this is not neaded just remove if you want this silenced 
       Camera.setFlash(ON); // Putting the flash on incase it night
       Camera.rearCapture(); //Taking the picture from back camera
       Twitter.tweetLastPicture("Posted with #1sheeld @1sheeld"); //posting the image to twitter
      // Facebook.postLastPicture("Posted by User");  //ENABLE this if you want to USE FACEBOOK          
       delay(1000); // Delay for 1 seconds sothat the value resets and th movement is different
       
    
    }
  } else { // if no movement
      digitalWrite(ledPin, LOW); // turn LED OFF        
      if (PIR== HIGH){ //nested if , if that value was HIGH , set to low and it wil check everything

      PIR = LOW;
      //loop restarts
    }
  }
}

Schematics

PIR- Motion sensor and 1sheeld
Untitled%20Sketch.fzz

Comments

Similar projects you might like

Motion activated SMS Shield- Tutorial

Project tutorial by Burger

  • 4,487 views
  • 2 comments
  • 5 respects

My Motion Activated SMS sender

Project tutorial by Christiaan Neil Burger

  • 2,172 views
  • 0 comments
  • 5 respects

Security System Using Arduino Bluetooth Camera

Project tutorial by amrmostaafaa

  • 13,173 views
  • 12 comments
  • 28 respects

Motion Activated Night Light

Project tutorial by Haziq Afandi

  • 5,088 views
  • 0 comments
  • 6 respects

Security System With 1Sheeld

Project showcase by nada abdelnaby mady

  • 2,013 views
  • 0 comments
  • 2 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 318,631 views
  • 101 comments
  • 767 respects
Add projectSign up / Login