Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

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

unsigned long lastUpdateValue = 0;
int brightness = 255;
uint16_t i;
uint32_t w = strip.Color(255, 255, 255); // soft white

void setup() {
    strip.begin();
    strip.show();
    Particle.function("tomato", setRed);
    // Particle.function("spinach", setGreen);
    // Particle.function("blueberry", setBlue);

}

void loop() {
    strip.show();
    
    if(w == 255) {
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, w); // set a color
            }
    }else{
       
        unsigned long timeNow = millis();
        if((timeNow-lastUpdateValue) >=1000){
            if(brightness > 0){
                for( int i = 0; i < strip.numPixels(); i++ ){
                strip.setPixelColor(i, brightness, 0, 255-brightness); //shifting color over a period of time 
                }
            strip.show();
            brightness = brightness-10;
            lastUpdateValue = timeNow;
            }
        }  
    }    
}
Click to Expand

Content Rating

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

0