Im trying to create a clock to use for automating LED events at a certain time of day (I do not want to buy a RTC), but for some reason in the clock I made it keeps contantly setting the seconds to 0 every time it runs. I have very little arduino coding experience.
Code :
String T = "Time: ";
String H = " hours, ";
String M = " minutes, ";
String S = " seconds";
int s;
int m;
int h;
void setup()
{
Serial.begin(9600);
}
void loop() {
delay(1000);
if (s < 60);
{
s = s + 1;
Serial.print("Time: ");
Serial.print(s);
Serial.println(S);
}
if (s = 60)
{
m = m + 1;
s = 0;
Serial.print("Time: ");
Serial.print(m);
Serial.print(M);
Serial.print(s);
Serial.println(S);
}
if (m = 60)
{
h += 1;
m = 0;
s = 0;
Serial.print("Time: ");
Serial.print(h);
Serial.print(H);
Serial.print(m);
Serial.print(M);
Serial.print(s);
Serial.println(S);
}
if (h = 24)
{
h = 0;
m = 0;
s = 0;
Serial.print("Time: ");
Serial.print(s);
Serial.println(S);
}
}