Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


bool lightStatus = false;

void setup() {

  light_ring.begin();
  light_ring.show(); // Initialize all pixels to 'off'
  
  Particle.function("sync-on",turnOn);
  Particle.function("sync-off",turnOff);

}


int turnOn(String command)
{
    lightStatus = true;
    return 0;
}


int turnOff(String command)
{
    lightStatus = false;
    return 0;
}


void loop(){
 
    
    if(lightStatus == true){
        
        for(int i=0; i<light_ring.numPixels(); i++){
            light_ring.setPixelColor(i,255,0,0); //red
        }
        light_ring.show();
        
    }else{
        
        for(int i=0; i<light_ring.numPixels(); i++){
            light_ring.setPixelColor(i,255,255,255); //white
        }
        light_ring.show();
    }
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0