Don’t know how to flag this posted as Solved, but it is… Thx everyone!!!
Enjoying reading ideas in this forum. Hoping to get some he lp that has me puzzled… I am new to Arduino programing but not with computer programming in general. (Better at PASCAL back in the 1980’s… lol)
I am writing a program for a pool heater… i have 4 dallas temperature sensors hooked up… the code is a medium size program so far… 700+ lines of code but not exceeding the arduino Mega SRAM or sketch memory… below is the memory usage of my sketch as it stands now.
Sketch uses 15030 bytes (5%) of program storage space. Maximum is 253952 bytes.
Global variables use 2166 bytes (26%) of dynamic memory, leaving 6026 bytes for local variables. Maximum is 8192 bytes.
couple of variables i use — there are many many more, but issues right now with these.
unsigned long TempReadingTime; // var used to time the loop counter
unsigned long LoopMax = 7000; // var only do temp check every 7 seconds.
I the void setup i have the following code…
NumberOfSensors = sensors.getDeviceCount(); // there are 4 sensors hooked up.
then there are the following commands
GetAndDisplayTemps(NumberOfSensors); // this procedure reads the sensors and displays on LCD
TempReadingTime = millis();
// do stuff like check for buttons being press
}while (millis()- TempReadingTime < LoopMax); // does the loop for 7 sec, then goes back to top of main program
when i have less procedure (voids) and the program is a bit smaller, it works wonderful… then i get to a point where i start to loose things… the NumberOfSensors goes back to 0 at the start of each loop of the main program… the first TempReadingTime is around 4160 on its first read thru. Then as i have problems with adding more code (the added code is not even executed because buttons have to be pressed in the do/while loop to get to it… and i’m not pressing them)
to find out what is going on… all i do is add Serial.print(" - stuff -"); to the code and now my NumberOfSensors will change to 50, after the second loop of the main program… have seen the TempReadingTime var go into the billions, with the arduino only being on for a minute or less.
After adding a few more Serial.print("… suff…"); to see the value of more variables… now the void loop() starts to execute … nothing displays on the Serial monitor, and the entire program starts over like you hit the reset button… and all i have added are Serial.print commands.
Just want to know if anyone has any ideas as to what might be happening. As i said, to a point the code works correctly and does what i want, just adding more code (that does not even get exe) caused issues with variables changing values and the are only changed in the void Setup().