I try to build a LED Strip Controller for WS2812B stripes.
The difficlulty is, it should control 2 different stripes simultaneously.
In my case both stripes are foldet and half parallel.
(1st 2x46 LEDs, 2nd 2x6 LEDs)
Furthermore there should be 2 buttons, one for each strip to:
change colour:
red, green, blue, purple, etc... (+black/off)
colour fade over black
colour fade from one colour to the other
rainbow -> fading from colour to colour and from one side to the other)
change motion:
filled colour
a small amount of LEDs runing from one side to the other around
a small amount of LEDs running parallel from one side to the other
strobe
police light (without colour mode)
Every colour should be combinable with every motion mode.
So for each stripe:
On a short press, change colour.
On a long press, change motion.
Thats the theory
Till now I finished two basic programs, but both are complete crap...
In the first the functions slowed down the controller taht much, that a button press wasnt recognized properly.
Even the second one which worked better is slow when I start the rainbow mode.
Besides I finally recognized that the program is that slow, that both stripes together didnt run smooth.
You could see the jump into the output function from one stripe to the other.
MY QUESTION :
Is it possible to realize that with an ATmega328p anyway or should I use two nanos, one for each stripe with 2 buttons each and work with interrupts?
Annexed is my last attempt.
I apprehend that I have to begin from scratch... :-/
Let's see your code. I am prepared to bet that you use the delay() function for timing and for loops to cycle through the sequences. If so then You need to look into using millis() for timing as in the BlinkWithoutDelay example and Several things at the same time
Save the time an event happens then each time through loop() check whether the required period has elapsed since the event. If not then go round loop() again reading inputs etc. If the period has elapsed then take the required action.
Use a state machine and switch/case to control which section(s) of code are active at any one time.
What are you using mills() and delay() for if it is not for timing actions ?
I guess my problem is, that the NeoPixel need to be lighted one by one what's normally done in a for loop.
But it doesn't have to be done in a for loop because the loop() function does what it says and loops.
Save the millis() value at the time that the start action, such as setting the value of an RGB LED happens. Then, each time through loop(), check whether the required wait period has elapsed by subtracting the start time from the millis() value now. If the period has elapsed then act accordingly, perhaps by updating the LED display and save the start time for the next activity. If not, then go round loop() again, perhaps taking other actions and/or reading inputs, but don't block the free running of loop().