Things used in this project

Hardware components:
Photon new
Particle Photon
11026 02
Jumper wires (generic)
Adafruit Simple 315 MHz RF Receiver
EMAX ES08A II servo
Adafruit 2 Button 315 MHz RF Transmitter


Photon 2
Circuit Diagram for Photon 2
Img 0439 yw515gcrsf
Photon 1 (RF Receiver)
Photon breadboard h6elblgaip


Code for Photon 2C/C++
The code for this photon controls the servo by moving the servo to pos1 when the unlock button is pressed and moving the servo to pos2 when the lock button is pressed.
Servo myservo;
int pos1=90; //servo position for light switch off
int pos2=0; //servo position for light switch on

void setup() {

myservo.attach(D0);//attatch servo pin to D0
Particle.subscribe("button_status", myHandler); //subscribe to 1st photon event

void loop() {}

void myHandler(const char *button_status, const char *data)

  if (strcmp(data,"on")==0) {
    // if your buddy's beam is intact, then turn your board LED off
  else if (strcmp(data,"off")==0) {
    // if your buddy's beam is broken, turn your board LED on
  else {
    // if the data is something else, don't do anything.
    // Really the data shouldn't be anything but those two listed above.
Code for Photon 1C/C++
The code for Photon 1 reads pin D4 (the pin connected to the output of the receiver) and publishes and event with a short data string based on the condition of the pin. If the pin reads HIGH then it will publish the data string "on" (instructing Photon 2 to activate the servo). If the pin reads LOW, it will publish the data string "off" (instructing Photon 2 to "close").
int rfr = D4;
bool button_changed=false;
void setup()
  pinMode(rfr, INPUT_PULLDOWN); 
void loop()
{ if (digitalRead(rfr)==HIGH) { 
    Particle.publish("button_status","on", 60, PUBLIC);}
      else {
        Particle.publish("button_status","off", 60, PUBLIC);}


Tyler Stogner
1 project • 0 followers
Grayson Bennett
1 project • 0 followers


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


Add projectSign up / Login