So I found this code for a nice pattern, but it has delays:
#include "FastLED.h"
#define NUM_LEDS_PER_STRIP 11
CRGB redLeds[NUM_LEDS_PER_STRIP];
CRGB blueLeds[NUM_LEDS_PER_STRIP];
void setup() {
// tell FastLED there's 60 NEOPIXEL leds on pin 10
FastLED.addLeds<NEOPIXEL, 12>(redLeds, NUM_LEDS_PER_STRIP);
// tell FastLED there's 60 NEOPIXEL leds on pin 12
FastLED.addLeds<NEOPIXEL, 13>(blueLeds, NUM_LEDS_PER_STRIP);
}
void loop() {
StripShow();
}
void StripShow(){
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
// set our current dot to red, green, and blue
redLeds[i] = CRGB::Red;
redLeds[i+1] = CRGB::Red;
blueLeds[i-1] = CRGB::Blue;
blueLeds[i-2] = CRGB::Blue;
FastLED.show();
// clear our current dot before we move on
redLeds[i] = CRGB::Black;
redLeds[i+1] = CRGB::Black;
blueLeds[i-1] = CRGB::Black;
blueLeds[i-2] = CRGB::Black;
delay(100);
}
for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
FastLED.show();
}
}
So I tried to get rid of them because that's important for where I'm going to implement the code.
#include "FastLED.h"
#define NUM_LEDS_PER_STRIP 11
CRGB redLeds[NUM_LEDS_PER_STRIP];
CRGB blueLeds[NUM_LEDS_PER_STRIP];
unsigned long interval= 500; // the time we need to wait
unsigned long previousMillis=0;
void setup() {
// tell FastLED there's 60 NEOPIXEL leds on pin 10
FastLED.addLeds<NEOPIXEL, 12>(redLeds, NUM_LEDS_PER_STRIP);
// tell FastLED there's 60 NEOPIXEL leds on pin 12
FastLED.addLeds<NEOPIXEL, 13>(blueLeds, NUM_LEDS_PER_STRIP);
}
void loop() {
StripShow();
}
void StripShow(){
unsigned long currentMillis = millis();
if ((unsigned long)(millis() - previousMillis) >= interval) {
previousMillis = millis();
for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
redLeds[i] = CRGB::Red;
redLeds[i+1] = CRGB::Red;
blueLeds[i-1] = CRGB::Blue;
blueLeds[i-2] = CRGB::Blue;
FastLED.show();
redLeds[i] = CRGB::Black;
redLeds[i+1] = CRGB::Black;
blueLeds[i-1] = CRGB::Black;
blueLeds[i-2] = CRGB::Black;
}
for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) {
FastLED.show();
}
}
}
But it doesn't work like the other one. In my head it works because everytime there has been gone by enough time (interval) a leds lights up and fades, but instead it flickers like it's got epilepsy.