Multiple led sequence over time

what should be in 'get data' ? an array of on state?

The correct member of your array. I sense a reluctance to code. You should go and program. All the directions have been given here, just follow the programming examples and documentation that Arduino provided. You already have a working sketch in reply #34, no?

I'm sorry if that what you feel.. I worked on that code and looked for solution more then 40 hours in two days and I feel with no direction of how to make it happen. I will try and start again from 1 led and continue from there.
Thanks for your help for the moment!

You have a program. What does it do now? Solution to what? You didn't identify any problems.

As you developed the sketch, was there any previous point when you were confident it worked? Then some sketch after it didn't work? Post the sketch that worked.

Also, you should try to comprehend my pseudocode example. It's really the simplest summary of what should happen...

As already mentioned, this will be a wiring nightmare. I would organise your LEDs into an 8x8 matrix and drive them with a max7219 chip. You can physically arrange the LEDs any way you like, just electrically wire them as a matrix

I have already cut and soldered 60 leds to 60 wires of 15 meter long... I'm affraid I cannot changed that. Those wire of the leds will be soldered to two stripboards that will be sitting next to the arduino.

Another solution would have been using 6 Arduino nano controlling 10 leds each one, each one near a group of 10 leds. The first Arduino also generates a sync pulse every second for all others.

Now you could drive leds 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ... by timing or a math function and the others by a table.

Example for led #0 (#8!):
if (t==0 || (t-1)%8 == 0)

For led #1 (#9!):
if (t==1 || (t-2)%8 ==0)

You still haven't explained your actual problem. What happens when you run your code? Without knowing that, it's nearly impossible to comment meaningfully.

But, I see one big conceptual commitment you've made. You are attempting to isolate and drive each LED separately, that is what your struct is for. Then you have an infrastructure to support individual blinking of each LED. This strikes me as excessively complicated. The LEDs appear to actually obey a fixed table and are all in sync, at least on an interval by interval basis. This is sort of like putting wheels on all the parts of your car so it will go when you put them all together.

With so many LEDs to control, and already having access to a "master timing diagram" definition in software, it's better to consider them as a group, rather than as a collection of individual blinkers.

I could not have so many nano at that moment, but I tried your code idea as the following:
void loop () {
Time=millis()/1000;
Time%=60;
Serial.println(Time);
if(Time == 0 || (Time -1)%8 ==0)
{
digitalWrite(5,HIGH);
}
else
digitalWrite(5,LOW);

if (Time==1 || (Time-2)%8 ==0)
{
digitalWrite(6,HIGH);
}
else
digitalWrite(6,LOW);
}

it seems to work fine apart of second 0 and 1 where for some reason led #0 is also on(second 0) while led #1 is on (second 1)

Ooops... They are #8 and #9!
Looking at the table, #8 must be on at time 0 and #9 must be on at time 1:

Example for led #0 (#8!):
if ((t==0 || (t-1)%8 == 0) && t!=1)

For led #1 (#9!):
if ((t==1 || (t-2)%8 == 0) && t!=2)

Are you aware, operations performed with % and millis(), will fall out of sync with timing produced by normal time stamp comparison code, after millis() rolls over in a few days?

The OP is struggling to implement what is basically a simple "player piano roll" approach. Now you want to throw complicated mathematical calculations into the mix? I think not a good idea...

Where did he write it has to run continuously for days?...

Anyway:
As I wrote in my post #11, he could write only the numbers of the leds on for each step, because only a few are on at the same time:
8, 13, 16;
9, 14, 27;
...
With a mean of 4 leds on, for a 15 minutes cycle:
15m60s4 leds on *1byte (256 leds max) = 3600 byte.

Where did he write that it doesn't? Don't a lot of programs run continuously? Also you are now forcing a novice programmer to invent new formulas every time there is a need to flash the LEDs differently. In fact, I doubt that this programmer can even understand what you're doing.

The OP has never stated the purpose for the flashing LEDs. If for any reason the timing chart needs to contain canonical sequences, and the implementation is based on mathematical formulas, it won't be possible.

Also, periodicity via the '%' operator, is horribly inefficient regards processor time and code space.

In 1 second, a 16MHz microcontroller should not have problems making a modulus and
some digitalWrite... :slight_smile:
You have to consider specific requirements. You can't optimize the code for maximum speed, if it isn't strictly needed, at the expense of required memory exceeding available memory...

True. But the actual problem is not how to do this more cleverly, or more efficiently. It is, how to make this something that a novice programmer could actually code and maintain.

Also, the processor in question has enough memory for a canonical data table (simple look up table). It's safer as well, because it gives you absolute and easily verifiable control over the maximum number of simultaneous active LEDs. I gave a memory estimate in post #14.

If it has to run continuously for days, there is anyway the problem: he makes (millis()/1000)%60! What happens at rollover?...
He has to read millis()/1000, compare the result with current seconds and, if they are different, increment a cyclic counter from 0 to 59. In this manner, there is only a single timing error less than 1 second at each rollover, instead of a sequence discontinuity.

The OP already has a working program in reply #9. They only need to make it fit in memory. They say they're new to programming. Why complicate things?

In #9 I see only 16 leds... 60 leds are about 4x. It become very difficult to write the right 1 or 0 at the right place! Writing a few 2-digit numbers would be simpler to write and immediate to read.

It's not as flexible. We don't know what this thing is for... suppose it's an art piece and one of the LEDs is supposed to follow Beethoven's "ode to joy". How are you going to code that? With a table, it's just a matter of filling in the blanks. If it is really unwieldy, it can be maintained in a spreadsheet, written to an SD card and read by the Arduino as suggested also above.

But again, I think this programmer will not be able to code it. So are you volunteering? :slight_smile: