EDIT: Problem Solved
Hello, I am new to this, just brought a elegoo started kit 2 weeks ago but loving it.
I'm working on a clock will hopefully eventually have this mechanical style illustration of all the planets in the solar system.
but for now I've been working on a normal clock with the second hand running of a stepper motor but I've ran into this problem that seems to be happening a few layers of code deeper. So there is this variable that counts the time of the last second, but when it reaches 32 seconds it starts counting backwards and messes everything up.
I made a simple example to show you what I mean:
int sec = 1000;
int lastSec;
int timeNow;
int tSec;
unsigned long time;
void setup() {
Serial.begin(9600);
}
void loop() {
 tSec = sec + lastSec;
 timeNow = millis();
 if (timeNow >= sec + lastSec)
  {Â
   lastSec += 1000;
           Serial.print("(B)timeNow  ");
           Serial.println(timeNow);
           Serial.print("(B) lastSec ");
           Serial.println(lastSec);
           Serial.print("(B) tSec");
           Serial.println(tSec);
           Serial.print("(B)sec ");
           Serial.println(sec);
  Â
  }
}
Then it gives:
timeNow 1000: lastSec 1000: tSec1000: sec 1000
timeNow 2000: lastSec 2000: tSec2000: sec 1000
timeNow 3000: lastSec 3000: tSec3000: sec 1000
timeNow 4000: lastSec 4000: tSec4000: sec 1000
timeNow 5000: lastSec 5000: tSec5000: sec 1000
timeNow 6000: lastSec 6000: tSec6000: sec 1000
timeNow 7000: lastSec 7000: tSec7000: sec 1000
timeNow 8000: lastSec 8000: tSec8000: sec 1000
timeNow 9000: lastSec 9000: tSec9000: sec 1000
timeNow 10000: lastSec 10000: tSec10000: sec 1000
timeNow 11000: lastSec 11000: tSec11000: sec 1000
timeNow 12000: lastSec 12000: tSec12000: sec 1000
timeNow 13000: lastSec 13000: tSec13000: sec 1000
timeNow 14000: lastSec 14000: tSec14000: sec 1000
timeNow 15000: lastSec 15000: tSec15000: sec 1000
timeNow 16000: lastSec 16000: tSec16000: sec 1000
timeNow 17000: lastSec 17000: tSec17000: sec 1000
timeNow 18000: lastSec 18000: tSec18000: sec 1000
timeNow 19000: lastSec 19000: tSec19000: sec 1000
timeNow 20000: lastSec 20000: tSec20000: sec 1000
timeNow 21000: lastSec 21000: tSec21000: sec 1000
timeNow 22000: lastSec 22000: tSec22000: sec 1000
timeNow 23000: lastSec 23000: tSec23000: sec 1000
timeNow 24000: lastSec 24000: tSec24000: sec 1000
timeNow 25000: lastSec 25000: tSec25000: sec 1000
timeNow 26000: lastSec 26000: tSec26000: sec 1000
timeNow 27000: lastSec 27000: tSec27000: sec 1000
timeNow 28000: lastSec 28000: tSec28000: sec 1000
timeNow 29000: lastSec 29000: tSec29000: sec 1000
timeNow 30000: lastSec 30000: tSec30000: sec 1000
timeNow 31000: lastSec 31000: tSec31000: sec 1000
timeNow 32000: lastSec 32000: tSec32000: sec 1000
timeNow 32001: lastSec -32536: tSec-32536: sec 1000
timeNow 32054: lastSec -31536: tSec-31536: sec 1000
timeNow 32116: lastSec -30536: tSec-30536: sec 1000
timeNow 32179: lastSec -29536: tSec-29536: sec 1000
timeNow 32241: lastSec -28536: tSec-28536: sec 1000
timeNow 32304: lastSec -27536: tSec-27536: sec 1000
timeNow 32366: lastSec -26536: tSec-26536: sec 1000
timeNow 32429: lastSec -25536: tSec-25536: sec 1000
timeNow 32491: lastSec -24536: tSec-24536: sec 1000
timeNow 32553: lastSec -23536: tSec-23536: sec 1000
timeNow 32616: lastSec -22536: tSec-22536: sec 1000
timeNow 32678: lastSec -21536: tSec-21536: sec 1000
timeNow 32741: lastSec -20536: tSec-20536: sec 1000
Any advice would be awsome
Thanks