Hello everyone I'm new here and to programing in general.

fastled-support
gplus
(Daniel Zettervall) #1

Hello everyone I’m new here and to programing in general. I recently bought an Alitove led strip with the plan to make stairlighting using my arduino uno.

The plan is to hook up two IR sensors to the top and bottom of the stairs and then depending on which of them is triggered make the leds light up from that direction and after a few seconds turn of in the same direction.

I’m having trouble finding that specific animation and figured I’d ask you guys for support.

Thanks in advance!

(Reko Meriö) #2

You should use for loop to do that. Maybe make 2 functions - other one will be called when sensor detects movement in upstairs and other one from downstairs. For example
for(int i = 0; i < NUMLEDS; i++){
led[i] = CHSV(250,250,250);
FastLED.show();
}
Maybe some delay here…
Then the same loop as above but reversed

(Reko Meriö) #3

I can make a more detailed answer when I get home if you need more help. Typing on phone is a bit slow :smiley:

(Daniel Zettervall) #4

@Reko_Merio Hey thank you for helping, I’d be really greatful if you could find the time to help me further :smiley:

(Reko Meriö) #5

Well here is something you could try:
//this will draw leds
for(int i = 0; i < NUM_LEDS; i++){
led[i] = CHSV(250,250,250);
FastLED.show();
}
//this will clear the strip
for(int i = 0; i < NUM_LEDS; i++){
led[i] = CHSV(0,0,0);
FastLED.show();
}
//some delay here is probably wanted, try it yourself

//this will do the same as previous but from other direction
for(int i = NUM_LEDS-1; i => 0; i-){
led[i] = CHSV(250,250,250);
FastLED.show();
}
for(int i = NUM_LEDS-1; i => 0; i-){
led[i] = CHSV(0,0,0);
FastLED.show();
}

Just add this inside loop() and I think it should work.
You will most likely want to use delays inside for loops but I cannot tell how much you will need

(Daniel Zettervall) #6

@Reko_Merio I tried that and it showed two errors:

error: expected primary-expression before ‘)’ token

for(int i = NUM_LEDS-1; i => 0; i-){

and

error: expected primary-expression before ‘>’ token

for(int i = NUM_LEDS-1; i => 0; i-){

If you want I can paste the whole code. Maybe that makes it a bit easier :smiley:

(Reko Meriö) #7

Sorry, there is a small typo on the last two loops.
It should be like this:
for(int i = NUM_LEDS-1; i >= 0; i–){

I have not tried this so I dont have the complete code, this is just something I thought would get you started

(варешяф рйезот) #8

@Reko_Merio there are easy way to set leds with one color:
leds(0,NUM_LEDS) = CRGB::Red;
leds(0,NUM_LEDS) = CRGB::Black;

more here: