how can I turn on LEDs,

gplus
(Sheena Variasi) #1

how can I turn on LEDs, if i want to turn on led 1 and 5 simultaneously?
some have the code?

(Marc Miller) #2

This would make them different colors, but light up at the same time.
leds[1] = CRGB(0,255,0);
leds[5] = CHSV(0,255,255);
FastLED.show();

Or this would also work and would make them both the same color.
leds[1] = leds[5] = CRGB(0,0,255);
FastLED.show();

The display of the pixels does not change until you call FastLED.show(). Make all your updates, and then call show to display all those updates at the same time.

(Sheena Variasi) #3

work sir, thank you.

the last question,
is there another way to blink the led besides this code?

leds[0] = CRGB(0,255,0);
leds[1] = CRGB(0,255,0);
leds[2] = CRGB(0,255,0);
leds[3] = CRGB(0,255,0);
leds[4] = CRGB(0,255,0);
leds[5] = CRGB(0,255,0);
FastLED.show();
FastLED.clear();
delay(50);
FastLED.show();
delay(50);

(Marc Miller) #4

Since you have a continuous range there [0-5], you can work that into a for loop. Have a look at the FastLED Cylon example for some ideas.

(Sheena Variasi) #5

i want the leds turn on same time but the leds has flashing effect like police light strobe.

(Michel G. Khoury) #6

What Marc meant is that you can use same code for loop than on the Cylon example. In particular this part :
for(int i = 4; i >= 0; i–) {
leds[i] = CHSV(0, 255, 255);
}
FastLED.show();

4 because you want 5 LEDs. And show() out of the loop because you want them all at the same time.

(Andrew Tuline) #7

Here’s a way to blink all 5 LED’s at once without any ‘delay’, ‘for’ or ‘if’ statements:

void loop () {
uint8_t j = (millis()/500) % 2; // bool works as well.
fill_solid(leds, 5, CHSV(0, 255, j*255));
FastLED.show();
} // loop()

Your loop will run at FULL speed.

Oh, and if you want to alternate between red and blue:

fill_solid(leds, 5, CHSV(j*160, 255, 255));

(Sheena Variasi) #8

@Andrew_Tuline thanks sir, i will try this.