Can Serial Monitor Be Used to Monitor Uno Countdown?

ah - I missed that added information.

then indeed the arduino makes sense

2 Likes

Have you heard the name of an unsigned 32-bit millisCounter which starts from 0 when the Uploading of a sketch in UNO is done and then it advances each count at 1 ms interval on interrupts?

The content of millisCounter can be read (on-the-fly) at any time using millis() function. Sample codes to blink L (onboard LED of UNO) at 1-sec interval using millis()/millisCounter:

unsigned long presentMillis = millis();  //record current time
int ledState = LOW;

void setup()
{
  pinMode(13, OUTPUT);
  digitalWrite(13, ledState);   //LED is off
}

void loop()
{
  if (millis() - presentMillis >= 1000) //1000 ms
  {
    ledState = !ledState;
    digitalWrite(13, ledState);
    presentMillis = millis(); //record current elapsed time
  }
  else
  {
    //do some other tasks 
  }
}

Thank you. I was not aware of the feature and I will look into it. Thank you for the tip and code.

1 Like

I will look at that now. Thanks so much for the getting me started.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.