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 light_ring = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
    
    light_ring.begin();
    light_ring.show(); // initialize everything to off. 
}
void loop() {
    // version 2
    // turn the neopixel on one by one
    for( int i = 0; i < light_ring.numPixels(); i++ ){
        light_ring.setPixelColor( i, 0, 100, 0 );
        // as this appears IN the loop
        // the changes appear one by one
        light_ring.show();
        delay( 500 ); // with a pause of 1/2 a second between them
    }
    // turn the neopixels off one by one 
    for( int i = 0; i < light_ring.numPixels(); i++ ){
        light_ring.setPixelColor( i, 0, 0 , 0 );
        // as this appears IN the loop
        // the changes appear one by one
        light_ring.show();
        delay( 500 ); // with a pause of 1/2 a second between them
    }
    light_ring.show();
    delay( 2000 ); 
}
Click to Expand

Content Rating

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

0