Things used in this project

Custom parts and enclosures

Img 20150918 170050 1


19-09-2015 11-24-49 م.png
19 09 2015%2011 24 49%20%d9%85


smart home scurtiy tiwiter.inoC/C++

Camera Shield Example

This example shows an application on 1Sheeld's camera shield.

By using this example, you can take a photo using your phone's
camera if the light sensor reads data above a certain threshold.


/* Include 1Sheeld library. */ 
#include <OneSheeld.h>

const int trigPin = 2;
const int echoPin = 4;

void setup()
  /* Start communication. */

void loop()
  // establish variables for duration of the ping, 
  // and the distance result in inches and centimeters:
  long duration, cm;

  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
    // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
 // convert the time into a distance
  cm = microsecondsToCentimeters(duration);
  /* Always get the value of the light sensor and make sure it is in a certain range. */
  if(cm < 100 && cm > 30)
    Terminal.println("Photo will be taken");
    /* Turn on the camera's flash while capturing. */
    /* Take a photo using the phone's rear camera. */
    /* Delay for 5 seconds. */
    String status = "status to be written to facebook along the picture";
    Twitter.tweetLastPicture(status , 0/1);


long microsecondsToCentimeters(long microseconds)
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;


10527368 1026026140759755 1265580077230329175 n
Ali Gamal
1 project • 0 followers


Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback


Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog