Need help with a short and simple yet confussing (atleast to me) piece of

Need help with a short and simple yet confussing (atleast to me) piece of code.

I had to write this out line by line on pastebin since i wont see my laptop for another 10 hours. But this is what i have so far for a single line showing up whenever i push a button. As it is right now it will start over if i push the button again while the line is still moving. What i want is for it to start a new line while the other line completes its course so if i only press the button once only 1 line shows up but if i hit the button more than once more lines will show up and do a full run down the strip. Any help is appreciated! :slight_smile:

https://pastebin.com/KbMJCkhQ

Sounds like you need to add code that will keep track of the LED’s position each time you push the button. Right now you’re resetting the position of the LED each time the button is pressed because the position is not being held when the button is pressed again.

One way you might do this is each time you press the button it sets the location to an array of integers and then the loop to display the LED checks each member of the array and sets that position on. You’ll also have to increment the positions as they move.

@Scott_Oliver any idea how to do that? Half of that went over my head lol

If I’m understanding you correctly, there are several different variations of what you’re describing in this sketch: https://github.com/jasoncoon/fastled-arcade

Video:

Jason’s project looks like a lot of fun. I’m thinking of something for next year’s Maker Faire in Vancouver and that’s a pretty cool idea.

@Jason_Coon AWESOME!!!

@Jason_Coon ​ on the main sketch you have FRAMES_PER_SECOND defined twice

Jason’s color pulse (from the video) looks like it’s doing something similar to what you’re asking for and has similar code to what I was describing. Very nice project Jason!

Trying to isolate it is hard. I only need 1 button lol

@Jason_Coon ​ how did you learn to code so well???

@Cristian_Martinez I have been at it for years, and it’s what I do for a living. I’m still learning and hope to never stop! :slight_smile: It definitely takes a lot of time and patience. Read and try to understand all of the code you find, especially the FastLED code and examples from Daniel and Mark! Start with DemoReel100. Don’t stop until you understand every single line. :slight_smile:

Thats good advice i appreciate it :slight_smile: