Hi All,
I am attempting to program hardware, which will allow users to manipulate settings for 8 LED's through rotary encoders. The settings are; picking LEDS (for further programming), specifying how bright these LED(s) should be; specifying how long they shine for. The user can see timings and power values on a LCD screen.
As there are potentially 8 groups of LED's, with 3 Settings each (A loop for setting LED's off or on, A loop for specifying brightness, A loop for specifying time), do I need 24 separate loops?
As I have it in my head, the key loops (on/off, brightness and time) are basically identical to each other, but the variables used in each loop have to change (to prevent the next group of LED's information being written to the same location as the previous group).
I have done basic c programming at university, but I have just come across array tables but never written one/used one and so I am unsure if they are suitable for my task? I was wondering if you could have 3 Identical loops which users step through, but there is an extra bit of code which sends the result of each loop to the next blank location in the array table?
This would obviously save me having to write out the same 3 loops (on/off, brightness, time) multiple times with very subtle differences.
Any help would be greatly appreciated!
I really think you are getting ahead of yourself way too much.
Your third requirement of setting the "on" duration of each LED requires that you understand the BlinkWithoutDelay example that is included in the IDE.
I suggest that you write a sketch that can have 3 LEDs blink for different durations. If you can do that, then go on with your initial project.
cheers for the initial direction,
i'll let you know how it goes
Hi again,
I have got 3 different LED's to blink at different rates with the attached code.
I am going to swap out the variable numbers for some code which uses rotary encoders to set the interval numbers.
I am slightly confused as why I am getting ahead of myself? Do you mean build up the complexity step by step? Or did you mean there is a much simpler way of doing what I wanted to do?
I am worried that my whole program will be a bit like the attached code, in which the program becomes huge as it is effectively repetitions of the same main loop over and over again with different variables (led2 instead of led1 etc).
There must be a smarter/quicker way of achieving the same results?
sketch_mar24b.ino (2.42 KB)
Yes, doing a single loop is realistic, you just need something like an identifier incrementing for each pass of the loop so the variables for each pass get saved to a unique location.
My understanding of identifiers in that sense is extremely limited. My understanding of them, is just a name for a variable?
How would I increment an identifier?