Zack DemopoulosPranav Nair
Published

Safe Alarm

With Safe Alarm, you will always have a sense of security knowing your valuables are kept at close watch.

IntermediateFull instructions provided2 hours693
Safe Alarm

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×3
Breadboard (generic)
Breadboard (generic)
×1
Photon
Particle Photon
×2

Software apps and online services

Maker service
IFTTT Maker service
Particle Pi
Particle Pi

Story

Read more

Schematics

Circuit Diagram

Graph of motion vs time

IFTTT screenshot

This is a screenshot from a cellular device. It shows the activity of the applet.

IFTTT screenshot

This screenshot displays the sequence of events that the applet calculates. The IFTTT applet first notices the "motiondetected" event being published. Then, the applet picks up the event and orders a notification sent to the application.

IFTTT applet screenshot

This is a screenshot of the applet itself.

Relationship Describing Sensitivity of Motion Sensor

Code

Motion detector Code

C/C++
This is the code for the photon with the PIR Motion Sensor. This code will allow the PIR Motion sensor to detect any form of motion.
int pirmotionsensor = LOW;
int inputmotion = D0;              
int LED7 = D7;                
int val = 0;                    

int calibrateTime = 3000000;      

void setup()
{
  pinMode(LED7, OUTPUT);
  pinMode(inputmotion, INPUT);     
}

void loop()
{
  if ( calibrated() )
  {
    readpirsensor();
    reportdata();
  }
}

void readpirsensor() 
{
  val = digitalRead(inputmotion);
}

bool calibrated() {
  return micros() - calibrateTime > 0;
}

void reportdata() {

  
 if (val == HIGH) {

    if (pirmotionsensor == LOW) {
     
      Particle.publish("motiondetected", "Motion");
      
      pirmotionsensor = HIGH;
      setLED(pirmotionsensor);
    }
  } else {
    if (pirmotionsensor == HIGH) {
     
      pirmotionsensor = LOW;
      setLED(pirmotionsensor);
    }
  }
}

void setLED(int state)
{
  digitalWrite(LED7, state);
}

LED light code

C/C++
This is the code for the photon with the LED. The code links this photon to the other photon with the PIR sensor attached to it. When the PIR sensor detects motion, the LED with this photon will light up.
int led = D7;
void setup() {

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

Particle.subscribe("motiondetected", mainPhoton, "2c0043000d47343438323536");


}

void mainPhoton(const char *event, const char *data)
{
  digitalWrite(led, HIGH);
  delay(3000);
digitalWrite(led,LOW);
delay(3000);

}
void loop() {

}

Credits

Zack Demopoulos

Zack Demopoulos

1 project • 0 followers
Pranav Nair

Pranav Nair

1 project • 0 followers

Comments