Mohit Bhoite
Published © MIT

Remote Motion Detection Using the Particle Electron

A PIR sensor based motion detector with IFTTT integration.

BeginnerFull instructions provided1 hour2,491
Remote Motion Detection Using the Particle Electron

Things used in this project

Story

Read more

Code

Particle Electron Motion detection

C/C++
#include "application.h"

//Uncommnent the following line to work in offline mode
//SYSTEM_MODE(MANUAL);

int led = D7; // we will use D7 LED to monitor sensor activity
int pir = D0; //connect the PIR output to pin D0 of the Electron

void setup() {
    pinMode(D0, INPUT_PULLDOWN);
    pinMode(D7,OUTPUT);
}

void loop() {
    if (digitalRead(D0) == HIGH) {
      digitalWrite(D7,HIGH); //show the activity of the sensor with the onboard D7 LED
      Particle.publish("motion","high",60); //publish an event 
      delay(1000);
        while (digitalRead(D0) == HIGH); // wait for the sensor to return back to normal
    }
    digitalWrite(D7,LOW);
}

Credits

Mohit Bhoite

Mohit Bhoite

6 projects • 38 followers
Solder junkie at Particle.io

Comments

Add projectSign up / Login