I want 10 red LEDs and next 10 white LEDs, and that repeated until I reach the end of the LED string.
This is the worst code, but it works.
What is the right way to do this? It must be very simple, but I can't figure it out
void Brabant() {
for (int i = 0; i < NUM_LEDS; i = i + 20) {
if (i < NUM_LEDS) {
leds[i] = CRGB::Red;
leds[i + 1] = CRGB::Red;
leds[i + 2] = CRGB::Red;
leds[i + 3] = CRGB::Red;
leds[i + 4] = CRGB::Red;
leds[i + 5] = CRGB::Red;
leds[i + 6] = CRGB::Red;
leds[i + 7] = CRGB::Red;
leds[i + 8] = CRGB::Red;
leds[i + 9] = CRGB::Red;
FastLED.show();
}
}
for (int i = 10; i < NUM_LEDS; i = i + 20) {
if (i < NUM_LEDS) {
leds[i] = CRGB::White;
leds[i + 1] = CRGB::White;
leds[i + 2] = CRGB::White;
leds[i + 3] = CRGB::White;
leds[i + 4] = CRGB::White;
leds[i + 5] = CRGB::White;
leds[i + 6] = CRGB::White;
leds[i + 7] = CRGB::White;
leds[i + 8] = CRGB::White;
leds[i + 9] = CRGB::White;
FastLED.show();
}
}
}