blinking external led with psu
technically works, but blinking incorrectly
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#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);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
leds[0] = CRGB(255, 0, 0);
|
||||
FastLED.show();
|
||||
delay(500);
|
||||
leds[1] = CRGB(0, 255, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user