Hi,
I have a strand of RGB leds that I cut into 78 LEDs (for size of the area) and I want it to be like a waving rainbow. Like the first LED is red and then orange, yellow, green, blue, purple, violet, and goes back to red all the way until the very end. I have seen many different tutorials but none of them are how I want it. I want it to be that this happens and then immediately I can start something else like press a button to make the whole thing red. So far all the programs have some sort of delay that makes the loop continue for sometime after it appears to be finished. Libraries like the Adafruit Neopixel Library have a rainbow function that has the rainbow but the rainbow is moving for around 40 seconds before the next function starts. So how do I make that function go straight into a new function?
Hello the0neand0nly
Welcome to the world's best Arduino forum ever.
Post your sketch, well formated, with well-tempered comments and in so called code tags "< code >" and schematic to see how we can help.
Have a nice day and enjoy coding in C++.
tutorials are there to teach you handle something. some are good, some not good, some erroneous. when you know you write own sketch and maybe own tutorial.
second thing, Neopixel lib have many functions and user is free to choose off moving, timing, coloring, fading, etc.
This is a problem that crops up several times a day.
The normal reply is to make your code none blocking by implementing a state machine. There are many examples of this but it involves removing all delays and "unwinding your loops" Which is may be too much for a beginner to take on board as it involves rewriting all your code.
I did come up with an alternative way of doing this by replacing all your delays with a commutable delay. That is one that can be cut short when a button is pressed.
There is a tutorial of how to do this at:-
It still involves a bit of thinking to get your head round and implement for your use, but I can assure you it is much simpler than the full state machine path.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.