Blink without Delay +fmod +proteus

In Blink without Delay example, I found out that the millis() function will reset its value each 50 days. Does that mean after 50 days, the LED might not blink anymore. So I use fmod function to overcome this disadvantage. But when I simulated the circuit with Proteus 78.0. The LED blinked each 3(s), not 1(s). Why? I haven't checked in practice yet.

Here is the code:

// constants won't change. Used here to set a pin number : const int ledPin = 13; // the number of the LED pin

// Variables will change : int ledState = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time // The value will quickly become too large for an int to store unsigned long previousMillis = 0; // will store last time LED was updated

// constants won't change : const long interval = 1000; // interval at which to blink (milliseconds)

void setup() { // set the digital pin as output: pinMode(ledPin, OUTPUT); } void loop() { unsigned long currentMillis = millis(); ** unsigned long checkingtime =0;** ** checkingtime= fmod (currentMillis,interval);**

** if ( checkingtime == 0) {** // if the LED is off turn it on and vice-versa: if (ledState == LOW) { ledState = HIGH; } else { ledState = LOW; }

// set the LED with the ledState of the variable: digitalWrite(ledPin, ledState); } }

Does that mean after 50 days, the LED might not blink anymore.

Does your life stop working when your mantelpiece clock flips over at midnight?

So I use fmod function

At what point did time become a floating-point quantity?

Groove:
Does your life stop working when your mantelpiece clock flips over at midnight?
At what point did time become a floating-point quantity?

Not understand what you mean. I tried with arduino Uno v3 and the result is: It blink 1s, turn off 1s, then 1s later LED is bright slightly, turn off 1(s) then is bright for 3s. Why??

And I don't understand why you used fmod to "overcome" a non-existent problem, so shall we call it quits?

Groove: And I don't understand why you used fmod to "overcome" a non-existent problem, so shall we call it quits?

Sorry. I didn't think carefully. You're right. OK. A lesson for me. Still do some research about my code so that I can understand fmod function. Still many thing to learn.

Forget fmod - it's a very simple function that is totally irrelevant in this context.

A very good explanation: http://www.gammon.com.au/millis