Back to Parent

#include <neopixel.h>


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

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

long timeAtParticleFuction = 0;
long turnOffAfter = 15*60*1000;

bool lightStatus = false;

void setup() {
  
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  
  Particle.function("turnOn", turnOn );
  Particle.function("turnOff", turnOff );

  
}

int turnOn(String command)
{
   lightStatus = true;
   timeAtParticleFuction = millis();
   return 0;
   
}
int turnOff(String command)
{
   lightStatus = false;
   timeAtParticleFuction = millis();
   return 0;
   
}

void loop() {


 uint16_t i;
 uint32_t cred = strip.Color(255, 0, 0);
 uint32_t cwhite = strip.Color(255, 255, 255);

 if(lightStatus == true){
      for(i=0; i< strip.numPixels(); i++) {
        strip.setPixelColor(i, cred );
      }
		strip.show();
		
  }else{
      for(i=0; i< strip.numPixels(); i++) {
        strip.setPixelColor(i, cwhite );
      }
		strip.show();

}

}
Click to Expand

Content Rating

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

0