How can I make LEDs blink randomly?
I found a piece of code, but it is not working for me. I probably need something other than setPixel(), but I don't know what.
I am using the Fast.Led library with Arduino Nano and WS2812B LEDs
void loop() {
Twinkle(CRGB::Red, 10, 100, false);
}
void Twinkle(uint32_t color, uint16_t Count, uint16_t SpeedDelay, boolean OnlyOne)
{
FastLED.setBrightness(MAX_BRIGHTNESS);
fill_solid(leds, random(NUM_LEDS), CRGB::White);
FastLED.show();
for (int i=0; i < Count; i++) {
// setPixel(random(NUM_LEDS),red,green,blue); //!ORIGINAL LINE OF CODE!
setPixel(random(NUM_LEDS), color); //!MY LINE!
FastLED.show();
delay(SpeedDelay);
if (OnlyOne) {
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
}
}
delay(SpeedDelay);
return;
}
setPixel()? Does the original code work at all? Remove the statements within exclamation marks and use proper comments for your code. A link to your library would also be nice.it is not working for me- what is it doing? Nothing blinks? Too many things blink? It isn't random? Aliens kidnap you and do scientific experiments on you? "Not working" doesn't tell us much.