// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#define PIXEL_PIN D3
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812
int otherColor;
unsigned long lastFade = 0;
int timeInterval = 15*60000;
// int timeInterval = 10000;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Particle.function("eventStart", fadeToRed);
lastFade = millis();
}
void loop() {
// fadeToWhite();
}
void setPixels(int intensity) {
uint16_t i;
uint32_t c = strip.Color(255, intensity, intensity);
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, c );
strip.show();
}
delay(100);
}
int fadeToRed(String command) {
// fade to red
otherColor = 255;
unsigned long now = millis();
while(otherColor>0) {
if ((now - lastFade) >= timeInterval/255) {
otherColor--;
lastFade = now;
}
setPixels(otherColor);
now = millis();
}
// fade to white
otherColor = 0;
while(otherColor<=255) {
if ((now - lastFade) >= timeInterval/255) {
otherColor++;
lastFade = now;
}
setPixels(otherColor);
now = millis();
}
return 1;
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .