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

2-Way Particle Photon Communication
Easy
  • 132
  • 4

Make two Particle Photons "talk" via the usage of webhooks!

E-Paper Weather Display with Photon and IFTTT
Easy
  • 749
  • 9

Full instructions

Create a beautiful medium for weather information using Particle's cloud services and IFTTT.

IFTTT - Enabled Sensors with Particle Photon
Easy
  • 660
  • 11

Full instructions

Connect any sensor to Particle Photon and use it to trigger an IFTTT action with just a few lines of code.

Light Detecting Email Sender
Easy
  • 208
  • 4

Full instructions

Receive an email about when the light is too strong on your device; nobody wants a heated device left directly under the sun. Photon + IFTTT

WiFi Strength Meter
Easy
  • 4
  • 0

A meter that indicates the Wi-Fi signal strength in an intuitive way, using the parts I had on hand.

Internet-Connected Popcorn Popper
Easy
  • 141
  • 1

Full instructions

A hot air popcorn popper triggered via the Internet! (Built for the Bellingham Codes May event.)

Add projectSign up / Login