CameronT
Published

Particle Photon and LIFX Bulb (using Webhooks)

Control Lifx bulbs with a Particle Photon.

AdvancedFull instructions provided2 hours1,213
Particle Photon and LIFX Bulb (using Webhooks)

Things used in this project

Hardware components

Photon
Particle Photon
×1
LIFX Bulb
Make sure you get the right type. The E27 one fits the Australian fittings. I selected the Colour 1000 unit as it provides RGB colours and fits most table lamps.
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×2
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

LIFX API

Story

Read more

Schematics

Wiring

Code

Particle Photon Code

C/C++
//This defines the inputPin that our button is connected to, to be D0
int inputPin = D0;
//This sets the 'LED' to be pin D7
int led = D7;

//Now we configure the Pins to be either inputs or outputs
void setup() {
   //Set D0 to be the input that we will connect our button to
   pinMode(inputPin, INPUT_PULLUP);
   //Set the LED pin (D7) to be an output
    pinMode(led, OUTPUT);
}

//NOTE MAKE SURE YOU PUT IN SUITABLE DELAYS
//This code will keep looping - to avoid having the webhook trigger 20
//times per 1 button press, make sure you have a delay that way it gives
//you enough time to lift your finger off the button before looping again.
//The API has a limit of 1 command every second.
void loop(){
int inputPinState;
   inputPinState = digitalRead(inputPin);
//first button checking state
 if(inputPinState == LOW){      // Check State of the PIN (i.e. if the button has been pressed)
    //This line of code is what triggers the webhook - make sure the webhook
//name and the name below match.
   Particle.publish("LIFX_TURN_ON_FRONT_DOOR");
   digitalWrite(led, HIGH);   // Turn ON the LED
   delay(1500);
 }
 else
 {
   digitalWrite(led, LOW);  // Turn the LED off
 }
}

Credits

CameronT

CameronT

2 projects • 4 followers
Thanks to Samdup.

Comments

Add projectSign up / Login