I have project, where I'm aiming to create a digital clock by turning on/off a rather large amount of leds.
So my initial idea is to define an array for each led that needs to be turned on to produce the number. For instance this array would turn on the leds to produce zero (In my actual setup there will be 48 leds in this case, here each numer represents a set of 8 leds together).
int D10[] = {1, 2, 3, 4, 5, 6};
Now to avoid writing a lot of code over and over the idea was to pass the array to a function and loop over it. But here's the problem; each array would have a different length (between 16 and 56 leds) - and as far as I've understood we can't calculate the length of the array.
The loop is rather simple:
for (int i = 0; i < 6; i++) {
leds[D10[i]] = CRGB::Red;
//FastLED.show();
//leds[4] = CRGB::Black;
}
Would it be an option to create another array that keeps information about the length of each array and use that in the loop? Or how would you suggest to do it?
What you can't do is to pass an array to a function and calculate the length of the array in the function. This is because what is passed to the function is a pointer to the array rather than the array itself and the pointer will always have the same length. What you can do is to pass the length of the array toa function along with the array
I'm not sure I follow? I need to know which leds should be turned on, the rest should be off. If I pass all leds in each digit I would produce the digit 8 all the time?
Ahh yes of course that makes sense! Wonder why I didn't think of this
Regarding the other note that was sort of my idea even if I didn't know quite how to do it. I have leds strips with 8 leds each (one module) that essencially should be treated as one as they are either all on or all off.