Skip to main content
Minor fixes, added link to FastLED, added C code formatting and indented code correctly
Source Link
Greenonline
  • 3.2k
  • 7
  • 37
  • 49

Random Blink ledsLEDs

How can I make ledsLEDs blink randomly? I

I found a piece of code, but it is not working for me. Probably I probably need something other then setPixelthan setPixel(), but I don't know what.

I am using Fast.Led library withthe Fast.Led library with Arduino Nano and and WS2812B ledsLEDs

    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++) {
!ORIGINAL LINE OF CODE! setPixel(random(NUM_LEDS),red,green,blue);
!MY LINE!         ....(random(NUM_LEDS), color);
         FastLED.show();
         delay(SpeedDelay);
         if(OnlyOne) {
              fill_solid(leds, NUM_LEDS, CRGB::Black);
              FastLED.show();
         }
       }
     
      delay(SpeedDelay);
      return;
    }
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;
}

Random Blink leds

How can I make leds blink randomly? I found a piece of code, but it is not working for me. Probably something other then setPixel, but I don't know what

I am using 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++) {
!ORIGINAL LINE OF CODE! setPixel(random(NUM_LEDS),red,green,blue);
!MY LINE!         ....(random(NUM_LEDS), color);
         FastLED.show();
         delay(SpeedDelay);
         if(OnlyOne) {
              fill_solid(leds, NUM_LEDS, CRGB::Black);
              FastLED.show();
         }
       }
     
      delay(SpeedDelay);
      return;
    }

Random Blink LEDs

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;
}
Source Link
Niles
  • 123
  • 2
  • 3
  • 9

Random Blink leds

How can I make leds blink randomly? I found a piece of code, but it is not working for me. Probably something other then setPixel, but I don't know what

I am using 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++) {
!ORIGINAL LINE OF CODE! setPixel(random(NUM_LEDS),red,green,blue);
!MY LINE!         ....(random(NUM_LEDS), color);
         FastLED.show();
         delay(SpeedDelay);
         if(OnlyOne) {
              fill_solid(leds, NUM_LEDS, CRGB::Black);
              FastLED.show();
         }
       }
     
      delay(SpeedDelay);
      return;
    }