Things used in this project

Hardware components:
Photon new
Particle Photon
13285 01
PIR Motion Sensor (generic)
11026 02
Jumper wires (generic)
12002 04
Breadboard (generic)
Servo (generic)
Car Cell Phone Holder
We used phone holder to hold the servo motor connected to the dead bolt.


Motion Sensor Diagram
It is the diagram of the motion sensor connected to the photon.
Motion sensor 9ecfzx21ef
Servo motor
It will lock and unlock the door when the motion sensor detects any motion.
Servo motor xicmomsygw


Servo MotorC/C++
Below, is the code for the servo motor attached to the subscribing Photon. When the photons gathers the code from its publisher, the servo will rotate 110 degree and wait 5000 milliseconds before reversing the rotation back to its original position.
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position
int led = D7;

void setup( ) {
  // attaches the servo on the D0 pin to the servo object

  // register the Spark function

  Particle.subscribe("motion-door", anything, "270039001147353230333635");

void anything(const char *event, const char *data)
     if (strcmp(data, "Movement")==0)

void loop()
Motion SensorC/C++
This is the code for the PIR sensor. Within the code, variables are initialized and when the sensor detects motion, the command below will publish to the cloud. The information that has been published to the cloud is then capture by the subscriber photon.
int PIRSensor = D0;
int state=0;
void setup(){

void loop() {
  if (digitalRead(PIRSensor) == HIGH){
       digitalWrite(D7, (state) ? HIGH : LOW);
       state = !state;



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


Similar projects you might like

Particle Photon Based Security System with Alerting
  • 1,345
  • 20

Full instructions

Be alerted to any door or window opening and closing in your house on your smart phone.

Happy Plant Notifier
  • 290
  • 5

Full instructions

Get a text or call if your plant is getting too dry, along with a nice LCD display giving information regarding your plant's health.

My Guardian for the Workshop
  • 202
  • 4

Full instructions

Device will send emails if the door or window has been opened, and will monitor the temperature and humidity of the place.

Smart and Safe Outdoor Plant Watering System
  • 2,526
  • 18

Monitors soil moisture and weather forecasts to give plants just the water they need. Safe garden hose hookup for season long watering.

Christmas Gift Box
  • 3,684
  • 595

Full instructions

Christmas Gift Box plays music and sends an email when it is opened.

Carbon Fiber Vacuum Chamber
  • 3,035
  • 94

Full instructions

Our project is a carbon fiber vacuum chamber that is monitored by multiple particle photons and various sensors.

Add projectSign up / Login