Things used in this project

Hardware components:
Photon new
Particle Photon
×2
Servo (generic)
×1
11026 02
Jumper wires (generic)
×6
12002 04
Breadboard (generic)
×2
13285 01
PIR Motion Sensor (generic)
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service

Schematics

Servo Motor Circuit
Servo circuit febpxgst8u
PIR Motion Sensor Circuit
Pir circuit m4kednbcsi

Code

PIR Motion SensorC/C++
This code allows photon 1 to publish an event to the cloud when motion is detected.
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-detected","light");
       state = !state;
       delay(1000);
   }
   delay(10);
}
Servo MotorC/C++
This code allows photon 2 to trigger the servo motor by subscribing to the event published by photon 1.
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created


int pos = 75;    // 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-detected", monkey, "4b0050001451353432393433");
}

void monkey(const char *event, const char *data)
{
     digitalWrite(led,HIGH);
     if (strcmp(data, "light")==0)
     {
myservo.write(115);
delay(1800000);
myservo.write(75);
     }
}


void loop()
{
  
}

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

What's My I2C Address?
Easy
  • 72
  • 3

The story of how to make a clock through using a LCD 1602 or LCD 2004 over I2C.

MyHumidity Controlled by BME280 and Photon
Easy
  • 181
  • 4

Full instructions

Checks if humidity threshold is reached and informs the user by using Blynk/IFTTT-services with softAP integration.

Tweeting Particle Photon
Easy
  • 42
  • 1

Full instructions

Tweet your friends with only the press of a button!

MyLight-Clock with NeoPixel Ring 12 Controlled by Photon
Easy
  • 260
  • 2

Full instructions

Read the time at night? Without glasses? Impossible? Focus on 2 light points, which will tell you the hour and the minute.

Map Your Particles!
Easy
  • 1,354
  • 20

Protip

Locate your Particle Photons, P1s and Electrons on a map without needing extra hardware. Use Ubidots or an offline map alternative

BME280 measures and displays on OLED controlled by Photon
Easy
  • 340
  • 2

Protip

I share my first steps with the sensor BME280 (temp / humi / pressure / altitude) and an OLED 128 * 64 px

Add projectSign up / Login