if hour is between 0-8 it works, but if it's above that, secondsElapsed returns near the maximum value of an unsigned long, that is a 429496xxxx ish number..
I have almost tried anything, calculating just with numbers instead of using time, (hour * (60^2)), ((hour * 1800)*2), and I've tried with normal long, unsigned int, and so on.. But nothing seems to work, can anyone help me?
Just FYI, you should remember from your nature/physical science course that one day has 86,400 seconds, far less than what long int or unsigned long so something else was wrong. 8 hour is about 32767, max of signed int, which is what all numerical constants are treated as without specific type case.
Correct. The compiler shoved a 10 into a 16 bit register, and 3600 into a 16 bit register, and multiplied the two registers, resulting in an overflow. The 16 bit value is then moved to a 32 bit memory location.
Had you said:
unsigned long temp = 10UL * 3600UL;
The compiler would have noticed that it needed to use 32 bit registers for the multiply operation, before moving the 32 bit result to a 32 bit memory location.