Skip to main content
Arduino

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

How to reset millis( )?

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

Answer*

Draft saved
Draft discarded
Cancel
6
  • I‘ve just added a picture of my program, maybe you‘re able to take a look Commented Jan 6, 2020 at 11:11
  • 3
    @Laurentien Please... don't post photographs of code. Post the actual code. Commented 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. Commented 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. Commented 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 Commented Jan 6, 2020 at 15:10

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /