#include "neopixel.h"
#define PIXEL_PIN D2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
unsigned long lastFade = 0;
int redPercentage=255;
void setup() {
strip.begin();
strip.show();
}
void loop() {
unsigned long now = millis();
if ((now - lastFade) >= 1000) {
if (redPercentage <= 255 && redPercentage > 0 ) {
if(redPercentage < 50) {
redPercentage = 0;
} else {
redPercentage = redPercentage - 50;
}
}
lastFade=now;
}
for(uint16_t i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, 255, redPercentage, redPercentage);
}
strip.show();
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .