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 D4
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812

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

void setup() {

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

void loop() {
    uint8_t wait = 500;
    uint32_t c = strip.Color(255, 255, 255);
    uint32_t off = strip.Color(0, 0, 0);

    colorWipe(c, wait, 0);
    colorWipe(off, wait, 1);

}

// Fill the dots one after the other with a color, wait (ms) after each one
void colorWipe(uint32_t c, uint8_t wait, uint8_t reverse) {
    if (reverse == 0) {
        for(uint16_t i=0; i<strip.numPixels(); i++) {
            strip.setPixelColor(i, c);
            strip.show();
            delay(wait);
        }
    } else if (reverse == 1) {
        for(uint16_t i=strip.numPixels()-1; i>0; i--) {
            strip.setPixelColor(i, c);
            strip.show();
            delay(wait);
        }
    } else {
        return;
    }
    return;
}
Click to Expand

Content Rating

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

0