igendel:
You can't use ++ this way. Create a loop to go over the elements and actually increase them one by one.
Here's what I'm intending to do. This is a part of mini weather station project. I want store store humidity, heat and pressure information every 1,2,3,4 and 5 hours. To measure time, I decided to create some integer arrays that increment one by one in every 20 secs. (There are several delay commands in void loop function, so it takes about 20 secs to loop and start again. So it increments 1 in every 20 secs.)
Then I wrote switch case code, if the integer in the arrays reach ".." number it means ".." hour passed so store the heat, humidity and pressure etc...
I'm not sure I understand... do you mean you want to do different kinds of measurements each time - for example, measure heat every single hour, but measure humidity only once every two hours?
If so, you could probably do with a single integer. Let's say it's called H and it represents full hours.
every time it changes (by your code of course), do this:
Measure heat
If H divides into 2 without reminder (i.e. H % 2 == 0), it means two hours have passed - measure humidity...
If you have a 5 element array you can (for example) set the value of each element to 27 like this
int myNumber = 27;
for (byte n = 0; n < 5; n++) {
myArray[n] = myNumber;
}
If you want to keep time over a long period you will need to use a Real Time Clock module because the Arduino millis() function is not accurate enough.
Do NOT use the delay() function in your code. If you want to manage small periods of time use millis() as illustrated in several things at a time
igendel:
I'm not sure I understand... do you mean you want to do different kinds of measurements each time - for example, measure heat every single hour, but measure humidity only once every two hours?
If so, you could probably do with a single integer. Let's say it's called H and it represents full hours.
every time it changes (by your code of course), do this:
Measure heat
If H divides into 2 without reminder (i.e. H % 2 == 0), it means two hours have passed - measure humidity...
No. For first hour, I use first integer in the array. For second i use second, for third, third array... it goes like that till 5.
If I don't do it like that, the columns I created on the 5110 LCD, which shows measurements for the first, second, third and fourth hours are not updated before fifth hour. I hope I made myself clear.
I've spent hours and hours on this code, I really tried lots of ways to do it and they all failed to deliver. Believe I wouldn't do it if it wasn't necessary.
But my programming skills aren't good. So if you would like to suggest a better way, I'm all ears.
Delta_G:
Maybe if you posted this code where we could see it, then someone could help you with it instead of just stabbing at the dark?
Sure, here you go. It's in Turkish though. I tried to translate some parts quickly but the rest of the code is in Turkish. Here are some helpful translations:
Some parts might look very confusing and that's because you're not familiar with the whole thing. I spent so much time and wrote this thing by trial and error way. I fiddled with so many little things in there but I feel comfortable when I see the it because I know what each piece of code does individually.
It won't fit in this post. So I'm attaching it here as a text file.