I am trying to make a very cool and therefore complicated LED lightworks.
Is it possible to write the sketches in a special way that allows one part of the lightworks to function the same while I tweak the other parts?
I mean, if I want to keep one LED blinking on for a second and off a second, is there a way to write that once and then forget about it while I make the rest of the sketch?
Currently the way I understand it is that I have to integrate codes for that one LED into the rest of the sketch and that makes it complicated!
I mean, if I want to keep one LED blinking on for a second and off a second, is there a way to write that once and then forget about it while I make the rest of the sketch?
I've done some sound activated lighting effects... I don't exactly have some LEDs blinking independently from others, but I have a stereo effect where the left & right channels are independent.
I have multiple "timers" with multiple LedState variables (actually a couple of type-longs where each bit represents the state of an LED), multiple previousMillis variables (such as previousMillis1) and various interval variables (such as interval1, etc.). There is only one currentMillis variable, because there is only one "current time".
I mostly avoid delay(), and it's a good idea to avoid delay() altogether because the program "freezes up" and can't do anything during the delay() time. But, I do use a couple of short delays where it doesn't hurt anything.
Then, there is a main loop and loops for each different lighting effect. Inside the loops, I call various functions. Some of the functions are only called depending on the various timers (or other variables). Like jurs, I have functions for reading the audio input, functions for manipulating the LED pattern (depending on timing and the audio, etc), and output functions that update the actual LED states.
... So, I have loops inside loops, multiple timers, and functions calling functions.