// ------------------------------------------------ // Controlling LifxLightBulb through Particle Cloud // @author Rahmadi Trimananda - UC Irvine // ------------------------------------------------ #include "LifxLightBulb.h" LifxLightBulb *llb1; LifxLightBulb *llb2; void setup() { // Bulb 1 string macAddress1 = "D073D5128E300000"; uint8_t devIPAddress1[] = { 192, 168, 1, 126 }; llb1 = new LifxLightBulb(devIPAddress1, macAddress1, 12345); llb1->init(); // Bulb 2 string macAddress2 = "D073D50241DA0000"; uint8_t devIPAddress2[] = { 192, 168, 1, 232 }; llb2 = new LifxLightBulb(devIPAddress2, macAddress2, 12346); llb2->init(); Particle.function("lifx1",lifx1Toggle); Particle.function("lifx2",lifx2Toggle); } void loop() { // Nothing to do here for(int i=0; i < 3; i++) { llb1->turnOff(); delay(1000); llb1->turnOn(); delay(1000); } } // Toggling Lifx light bulb 1 int lifx1Toggle(String command) { if (command=="on") { llb1->turnOn(); return 1; } else if (command=="off") { llb1->turnOff(); return 0; } else { return -1; } } // Toggling Lifx light bulb 2 int lifx2Toggle(String command) { if (command=="on") { llb2->turnOn(); return 1; } else if (command=="off") { llb2->turnOff(); return 0; } else { return -1; } }