John,
Try replacing this:
void loop (){
currentMillis = millis() ;
if(currentMillis > previousMillis)
{
previousMillis = currentMillis +1000;
with
void loop (){
currentMicros = micros() ;
elapsedMicros = currentMicros - previousMicros
if(elapsedMicros > duration)
{
previousMicros = previousMicros + duration;
hundredths = hundreths +1;
(if hundredths == 10){
hundredths = 0;
tenths = tenths +1;
if (tenths == 10){
tenths = 0;
secU = secU +1;
}
}
}
with
unsigned long currentMicros;
unsigned long previousMicros;
unsigned long elapsedMicros;
unsigned long duration = 1000000UL;
byte tenths;
byte hundredths;
I usually keep track of 0.01S, setting duration to 10000UL and having a
hundreths and tenths counter.
The key is here tho:
previousMicros = previousMicros + duration;
So the next time event is always set the same, and not varying a little by how long the code might take in between loop passes.