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 is the class, or library that is called, for the variable ‘strip’ (similar to int, bool)
Adafruit_NeoPixel strip = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

bool eventLightUp=false; 

void setup() {
    strip.begin ();
    strip.show();  
    
    Particle.function("eventLightUp",handleHandleLightUp);
}

void loop() {
    if (eventLightUp==true){
        for (int k=0; k<256; k++){
            for (int i=0; i<strip.numPixels(); i++){
                strip.setPixelColor(i, k/2,k,k);
            
                strip.show();
                delay(100);
                }
         }
    
        for (int k=256; k>=0; k--){
            for (int i=0; i<strip.numPixels(); i++){
                strip.setPixelColor(i, k/2,k,k);
            
                strip.show();
                delay(10);
                }
        }
    
    delay(100);
    
    }
    else{
        for(int i=0;i<strip.numPixels();i++){
            strip.setPixelColor(i,250,0,0);
        
        strip.show();
        delay(10);
        }
    }
}

int handleHandleLightUp (String cmd){
   
    eventLightUp=true;
    
    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