e905be01b6
technically works, but blinking incorrectly
44 lines
861 B
Arduino
44 lines
861 B
Arduino
#include <FastLED.h>
|
|
|
|
#define LED_PIN 15
|
|
#define NUM_LEDS 5
|
|
|
|
CRGB leds[NUM_LEDS];
|
|
|
|
void setup() {
|
|
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
|
|
FastLED.setBrightness(128);
|
|
FastLED.clear(true);
|
|
}
|
|
|
|
// Helper: blink one LED with a color then turn it off
|
|
void blinkLED(int idx, CRGB color, int onMs = 300, int offMs = 150) {
|
|
if (idx < 0 || idx >= NUM_LEDS) return;
|
|
|
|
leds[idx] = color;
|
|
FastLED.show();
|
|
delay(onMs);
|
|
|
|
leds[idx] = CRGB::Black;
|
|
FastLED.show();
|
|
delay(offMs);
|
|
}
|
|
|
|
void loop() {
|
|
// Make sure all LEDs start off
|
|
FastLED.clear();
|
|
FastLED.show();
|
|
|
|
for (int i = 0; i < NUM_LEDS; i++) {
|
|
// R -> G -> B for this LED
|
|
blinkLED(i, CRGB::Red);
|
|
blinkLED(i, CRGB::Green);
|
|
blinkLED(i, CRGB::Blue);
|
|
|
|
// Ensure it's off before moving on
|
|
leds[i] = CRGB::Black;
|
|
FastLED.show();
|
|
delay(200);
|
|
}
|
|
}
|