Hi all, I'm using the ws2812B leds with fastled on my arduino.

Hi all, I’m using the ws2812B leds with fastled on my arduino. I’m trying to have it so I can turn on any led with a serial input and have it stay on a certain amount of time, while also allowing me to turn on another led in the mean time to do the same thing. Each led will have its own unique time to stay on. I am having a lot of trouble with this and would love to hear others insight.
I appreciate any help. I attached a link to my code just to give a better visual of what I am trying to accomplish.
Thanks!
https://github.com/MrCodingRobot/SKORE/blob/master/arduino/LED_Code(NF)

@Zach_Bosker you mean that each led once in will stay during an amount of time which is different for each led right ?

@Zach_Bosker

try this. there is a duration array which stores the duration that a led should be on for each led in milliseconds

There could be a problem using serial input with FastLED on an UNO/Nano/similar Arduino. This is why I use APA102’s when using anything but basic inputs here. So, before commiting an entire program to what you want, make sure that serial communications still works while displaying a test FastLED routine.

See this:

@Yves_BAZIN This was exactly what I was trying to accomplish. Thanks so much. Though most importantly I am having trouble seeing what was wrong with my code. Is it just better practice to store the duration in an array, or the flow of my code? Since I do have everything in one loop essentially.
I appreciate the help again.

Update: Also is it possible to have the serial monitor receive a 2 digit number, like 15 and not read it as 1, 5? I understand Parse int is usually used but tends to have a delay. And i feel if i shorten that delay to much the led timing may become an issue.

@Zach_Bosker happy that he works for you.
Better practice I don’t know but way easier than having 100 variables if you have 100 leds and more flexible.
https://www.arduino.cc/en/Reference/ParseInt
This should help you use parsint
Or you could use
This insight
http://forum.arduino.cc/index.php?topic=217797.0
Let me know

@Yves_BAZIN Went ahead and used ParseInt and just shortened the timeout for it. Next I need to find a way to read it from a csv or midi file and find out how to set the led and the duration in one entry from those files. Thanks so much for the help!

@Zach_Bosker what do you wanna do exactly ?

@Yves_BAZIN N Ultimately my final goal is to have each LED resemble a note on a piano. The led that will light up and its duration will eventually come from either a MIDI file directly or a CSV file created from a MIDI file. And the strip will be capable of “teaching” you a song by playing the songs notes one after another

@Zach_Bosker ah oki :wink:
So you have several choices

  1. read the midi file from your computer and send via serial the commands
    2)store the midi file in a SD card and have it read from the arduino directly
    In both case you will need to know the structures of the midi file.

@Yves_BAZIN Yeah this is the next adventure for me haha. I’ll most likely have to translate it for my arduino using python and have the tablet Im using send via serial commands. Hopefully the serial response doesn’t cause to much delay so the song can play real time. But we shall see!
Thanks again for all of the help!!

@Zach_Bosker good luck. Can’t wait for you to show the final result