I seem to be getting unexpected result with the compiler and I'll try my best track this down and document what exactly is happening. I spent a good amount of time hung up on this one.
Around the same time that I moved to multidimensional arrays, I started having problems reading from my sensors. The old manner was like such:
int shtData = 3;
int shtClk = 2;
pinMode(ledPin, OUTPUT); // sets the digital pin 13 as output
Serial.begin(115200); // open serial
logPtr = logPtr + 1;
if (logPtr > logSize) logPtr = 0; logTime = millis();
localLogH[logPtr] = retVal;
and all was well. Then, to further complicate things, a total of 8 sensors was added. Four of these are actually two separate SHT11's with both temperature and humidity. The new code was something like this:
int shtClk = 2; // Common clock for both SHT11's
int shtData; // Selectable data pin
But there is a problem. For some reason, further on in the program, shtClk reads 0. Somewhere along the way, this variable is either not getting set, or getting reset. By putting a shtClk=2 in my setup() routine right before resetting the connection, everything works as expected. But initializing the variable in the definitions, it does not retain its value. Everything else in my program works properly, and I have checked to make sure that my arrays were been properly referenced and nothing was overwriting memory at any point.
I know that this is not a very... defining description of the rest of the program, but I can post additional information if necessary. I'm more curious if I am misunderstanding how initialization of variables works, or if this is actually a bug, and if anyone has encountered it before. I can move around where my program sets the variable in my setup() routine, to see if I can't figure out where it goes wrong.
Thanks for the help.