Hello
I need to create 4 variables for a time project:
countMU (count minutes units)
countMD (count minutes decades)
countHU (count hours units)
countHD (count hours decades)
The code is:
int numeroLCD[] = {2, 3, 4, 5};
int strobeLCD[] = {6, 7, 8, 9};
int countMU = 9; //count minutes unites
int countMD = 5; //count minutes decade
int countHU = 3; //count hours unites
int countHD = 2; //count hours decade
byte countMin;
byte countHr;
void setup(void)
{
for (byte i = 0; i < 4; i++) {
pinMode(numeroLCD[i], OUTPUT);
}
for (byte i = 0; i < 4; i++) {
pinMode(strobeLCD[i], OUTPUT);
}
Serial.begin(9600);
}
void loop(void)
{
countMU = (countMU + 1);
if (countMU > 9)
{
countMU = 0;
countMD = countMD + 1;
if (countMD > 5)
{
countMD = 0;
countHU = countHU + 1;
Serial.print(countHD);
Serial.println(countHU);
if (countHD < 2)
{
Serial.print(countHD);
Serial.print(countHU);
Serial.println(": <2");
if (countHU > 9)
{
Serial.println("> 9");
countHU = 0;
}
}
if (countHD = 2)
{
Serial.print(countHD);
Serial.print(countHU);
Serial.println(": =2");
if (countHU > 3)
{
Serial.println("> 3");
countHU = 0;
countHD = 0;
}
}
}
}
Serial.print(countHD);
Serial.print(countHU);
Serial.print(":");
Serial.print(countMD);
Serial.println(countMU);
delay(500);
}
The problem is that in the serial monitor I get:
00:59
01
01: <2
21: =2
21:00
21:01
I have added meany Serial print to try to find the problem. But between
Serail.print(": <") and Serial print(": =2) the is only one place where I use the variable countHD.
As you can see the Serial.print("> 9") is not printed so the if is not true. Just in case I have commented this countHD = countHD + 1, even deleted it but still the same.
I really don't understand the probblem
BR
Manuel