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);

void setup() {

    strip.begin();
    strip.show();   //Initialize all pixels to 'off'
    
}

void loop() {
    
    uint16_t i;
    uint32_t b = strip.Color(0, 0, 255);
    uint32_t r = strip.Color(255, 0, 0);
    uint32_t g = strip.Color(0, 255, 0);
    uint32_t w = strip.Color(255, 255, 255);
    
    //Switch on each pixel in blue all at once
    for(i=0; i<strip.numPixels(); i++){
        
        strip.setPixelColor( i, b);

    }
    strip.show();
    delay(1000);
    
    //Switch on each pixel in red all at once
    for(i=0; i<strip.numPixels(); i++){
        
        strip.setPixelColor( i, r);

    }
    strip.show();
    delay(1000);
    
    //Switch on each pixel in green all at once
    for(i=0; i<strip.numPixels(); i++){
        
        strip.setPixelColor( i, g);

    }
    strip.show();
    delay(1000);
    
    //Switch on each pixel in white all at once
    for(i=0; i<strip.numPixels(); i++){
        
        strip.setPixelColor( i, w);

    }
    strip.show();
    delay(1000);
}
Click to Expand

Content Rating

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

0