Plese help me: array [] with strage behavior

I have a strage or probably not strage behavior with a array. I have in my code define a array with two values.

unsigned long maxdata[maxAnz] {10, 2000};  

The first position 0 = 10, I´m using it as a value for a cycle counter inside my program and this value appears also on my Display to show the cycles.
The second position 1 = 2000, I´m using it as a value for a waiting time where it work with millis funktion. This value I use it also to show up on the Display.

10 cycles
2000 waiting time in milliseconds

Inside my Code I´m monitoring this values over The serial Monitor. On this way i can see what is happening.

Now to the problem that i have and i can see it over the Serial Monitor. The serial Monitor shows me for the counter = 10, for the timer it shows me = 4294967295 instead of 20000.
Like this my Code does not work properly. The counter works like it as to be, the waiting time of 2 seconds does not react like it would be.
I also changed the position inside the array for the counter and the time. That the value of the time is in the first and the counter in the second position.

unsigned long maxdata[maxAnz] {2000, 10};  

Like this the time works fine but the counter does not work.
Over the serial Monitor i can see always the second value being “4294967295” instead of what i need.

What is wrong? It is normal that the array works like this or I´m using it on a wrong way

Thanks in advance

Please post complete code.

Try

unsigned long maxdata[] {10, 2000}; 

@killzone_kid
I need to be

unsigned long maxdata[maxAnz] {10, 2000}; 

Or i have to change more things in the Code

@sterretje
@killzone_kid

Ok… i found out what is the problem
There is no problem with the array or the code.
The problem is me. Over the Oled the second array value i put it to -1 and it was saved in the Eeprom. I forgott that is was like this.

Puting

unsigned long maxdata[] {10, 2000}; 

like you told @killzone_kid helpt me to realize it.

Thnaks for the help

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.