// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
- if(currentMillis - previousMillis > interval) {
- // save the last time you blinked the LED
- previousMillis = currentMillis;
+ if (millis() > previousMillis + interval) {
+ // Aggiorniamo il contatore previousMillis
+ previousMillis = millis();
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);