Back to Parent

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


//Set pixel COUNT, PIN, and TYPE 
#define PIXEL_COUNT 16
#define PIXEL_PIN D5
#define PIXEL_TYPE WS2812

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

//Set variables for colors to store values values from cloud
int red = 0;
int green = 0;
int blue = 0;

void setup() {

    strip.begin();
    strip.show();   //Initialize all pixels to 'off'
    
    //Particle function on cloud
    Particle.function("Red", getRedColor);
    Particle.function("Green", getGrreenColor);
    Particle.function("Blue",getBlueColor);
    
    
}

void loop() {
    
    uint16_t i;
    
    //Switch on each pixel all at once
    for(i=0; i<strip.numPixels(); i++){
        
        strip.setPixelColor( i, red, green, blue);
        strip.show();
        
    }
    
    delay(100);
    
}


//Function to get command or value for red color from cloud
int getRedColor(String command){
    int  value = atoi(command);
    if(value >= 0 && value <= 255){
        red = value;
        return 1;
    }
    return -1;
}

//Function to get command or value  for green color from cloud
int getGrreenColor(String command){
    int  value = atoi(command);
    if(value >= 0 && value <= 255){
        green = value;
        return 1;
    }
    return -1;
}

////Function to get command or value for blue color from cloud
int  getBlueColor(String command){
    int  value = atoi(command);
    if(value >= 0 && value <= 255){
        blue = value;
        return 1;
    }
    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