Hi guys, I need to make a very basic arithmetic calculation however the result is not correct.
Below code is just a small part of the whole code, everything works as expected in the rest of the code. I just added below calculation to code.
lightOnTime = H[9]*3600 + M[9]*60 + S[9];
I use serialprint before the calculation to make sure below values are correct.
H[9] = 16
M[9] = 45
S[9] = 0
H[10] = 20
M[10] = 15
S[10] = 0
So the lightOnTime calculation should result 60.300 but instead it results 8176.
lightOffTime calculation should result 72.900 however it results 4294959360
What is wrong here?
unsigned long currentTime = 0;
unsigned long lightOnTime = 0;
unsigned long lightOffTime = 0;
byte H[15];
byte M[15];
byte S[15];
void setup()
{
byte H[15] = {5, 2, 6, 11, 12, 14, 15, 17, 21, 16, 20, 0, 0, 0, 0};
byte M[15] = {0, 0, 30, 0, 30, 0, 30, 0, 30, 45, 15, 0, 0, 5, 0};
byte S[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 45, 0, 5};
currentTime = hour()*3600 + minute()*60 + second();
lightOnTime = H[9]*3600 + M[9]*60 + S[9];
lightOffTime = H[10]*3600 + M[10]*60 + S[10];
}