Things used in this project

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

Schematics

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

Code

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( ) {
    pinMode(led,OUTPUT);
    digitalWrite(led,LOW);
  // attaches the servo on the D0 pin to the servo object
  myservo.attach(D0);

  // register the Spark function

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

void anything(const char *event, const char *data)
{
     digitalWrite(led,HIGH);
     if (strcmp(data, "Movement")==0)
     {
myservo.write(110);
delay(5000);
myservo.write(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(){
pinMode(D7,OUTPUT);
pinMode(PIRSensor,INPUT);
}

void loop() {
    
  if (digitalRead(PIRSensor) == HIGH){
       digitalWrite(D7, (state) ? HIGH : LOW);
       Particle.publish("motion-door","Movement");
       state = !state;
       delay(5000);
   }
   delay(10);
}

Credits

Replications

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

Comments

Similar projects you might like

AquaNiner Pet Hydration Monitor
Intermediate
  • 382
  • 14

Full instructions

Using two Photons, IFTTT and ThingSpeak, get notifications for when your furry friend needs water and monitor how much they're drinking.

Hot Shot Hoops
Intermediate
  • 530
  • 13

Full instructions

No need to keep track of the number of baskets you make when shooting hoops. Hot Shot Hoops does the work for you.

Hot Shot Hoops

Team IOT Basketball

Temperature Mirror
Intermediate
  • 381
  • 8

Full instructions

The Temperature Mirror incorporates a digital display to allow its user to readily view time, temperature, humidity, and light.

Temperature Mirror

MEGR3171 Team 49

Pet Feeder
Intermediate
  • 414
  • 7

Full instructions

Automated pet food dispenser to feed our pets when we are not at home by using an IoT device.

Teacher Tracker
Intermediate
  • 176
  • 4

Full instructions

If you want to know when a professor comes back to his/her office so you can ask annoying questions then this an option

LightAlert
Intermediate
  • 138
  • 4

Full instructions

As the great Terry Crews once said "that's 49 cents of milk spilt over the table! Somebody's gonna drink that!" But instead... electricity.

Add projectSign up / Login
Respect project