Back to Parent

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

#define PIXEL_PIN D0
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
bool fadeRed = false;
bool fadeWhite = false;
unsigned long turnRed = 6000;
int lightness = 100;
uint32_t c = strip.Color(lightness, lightness, lightness);
unsigned long countTime = 0;

void setup() {
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
    Particle.function("15minAlarm", ledControl15min);
    Particle.variable("lightness", &lightness, INT);

}

void loop() {
    uint16_t i;
    if(fadeRed && millis() - countTime >= 60){
        lightness -= 1;
        c = strip.Color(100, lightness, lightness);
        if(lightness <= 0){
            fadeRed = false;
            fadeWhite = true;
        }
        countTime = millis();
    }else{
        if(fadeWhite && millis() - countTime >= 60){
            lightness += 1;
            c = strip.Color(100, lightness, lightness);
            if(lightness >= 100){
                fadeWhite = false;
            }
            countTime = millis();
        }
    }
    
    for(i=0; i< strip.numPixels(); i++) {
            strip.setPixelColor(i, c );
        }
    strip.show();
}

int ledControl15min(String command){
    fadeRed = true;
    countTime = 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!

0