I'm trying to light my LED strip while running other stuff, unfortunately the example below uses the delay() function which is interrupting the motor movement.
#include <FastLED.h>
#define NUM_LEDS 6
#define DATA_PIN 5
CRGB leds[NUM_LEDS];
void setup()
{
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
}
void loop()
{
for(int x = 0; x < NUM_LEDS; x++)
{
leds[x].setRGB(255,69,0);
FastLED.show();
delay (50); //This is what I need to replace
leds[x] = CRGB::Black;
}
}
I can't figure how to use millis() in my case:
unsigned long startMillis;
unsigned long currentMillis;
const unsigned long period = 1000;
const byte ledPin = 13;
void setup()
{
pinMode(ledPin, OUTPUT);
startMillis = millis();
}
void loop()
{
currentMillis = millis();
if (currentMillis - startMillis >= period)
{
digitalWrite(ledPin, !digitalRead(ledPin));
startMillis = currentMillis;
}
}