I have the following code which is used to consecutively turn neopixels on in my strip. Problem is I would like to try and have it so the pixels slowly fade in.
Can anyone recommend what is the best way to try and do this.
Thank you
#include <Adafruit_NeoPixel.h>
#define PIN 8
#define NUM_LED 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LED, PIN, NEO_GRB + NEO_KHZ800);
const uint32_t RED = strip.Color(255, 0, 0);
const uint32_t OFF = strip.Color(0, 0, 0);
unsigned long startTime = millis();
boolean isFiveSecondsElapsed = false;
uint8_t index = 0;
void setup() {
strip.begin();
strip.setBrightness(64);
SetAllPixelsToOff();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
if (millis() - startTime >= 5000)
{
isFiveSecondsElapsed = true;
}
if (isFiveSecondsElapsed)
{
strip.setPixelColor(index, RED);
strip.show();
index++;
if (index >6)
{
index = 0;
SetAllPixelsToOff();
}
isFiveSecondsElapsed = false;
startTime = millis();
}
}
void SetAllPixelsToOff()
{
for (uint8_t i = 0; i < NUM_LED; i++)
{
strip.setPixelColor(i, OFF);
}
strip.show();
}