I am currently doing a school project. There you have to program a stopwatch with the Arduino. I wrote a program where millis starts. But when I press my start button, millis don‘t start from 0. Has someone an idea? Please let me know.

Ps: I‘m German, so I‘m sorry for my bad English enter image description here

1 Answer 1


You don't. Instead you just remember what millis() was when you pressed your start button, then subtract that from whatever millis() is showing at any other point in the future.

  • I‘ve just added a picture of my program, maybe you‘re able to take a look
    – Laurentien
    Jan 6, 2020 at 11:11
  • 3
    @Laurentien Please... don't post photographs of code. Post the actual code.
    – Majenko
    Jan 6, 2020 at 11:45
  • BTW: millis() returns an unsigned long. That will make a difference after 24 days of continuous running. And it will allow running forever, even when that unsigned long will roll over. Jan 6, 2020 at 12:14
  • @DataFiddler but doing stopmillis-startmillis will always return the correct value if the time between start and stop is less than the 24-day rollover. Jan 6, 2020 at 13:10
  • It's a 49+ day rollover. unsigned long lets millis() return from 0 to 4,294,967,295 mS. x 1 second/1000mS, x 1 minute/60 seconds, x 1 hour/60 minutes, x 1 day/24 hours = 49.59 days
    – CrossRoads
    Jan 6, 2020 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.