]> git.piffa.net Git - sketchbook_andrea/blobdiff - multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino
Multitasking
[sketchbook_andrea] / multitasking / BlinkWithoutDelay_7_struct / BlinkWithoutDelay_7_struct.ino
index e72666285569423af9762ee8e6c6b2cc2966c32c..8b555279498cbca4d3b33fef1d0f6ebcb5ad9992 100644 (file)
@@ -37,9 +37,9 @@ void loop()
 struct blinkLed lightLed(struct blinkLed temp) { // dataType tipo_di_struct nome_funzione(argomenti)
   // Illumina il ledA secondo un intervallo passato come argomento
 
-  if (millis() > temp.previousMillis + temp.interval) { // gli elementi dello struct sono accessibili tramite l'operatore [punto]
+  if (millis() - temp.previousMillis >= temp.interval) { // gli elementi dello struct sono accessibili tramite l'operatore [punto]
     // save the last time you blinked the LED 
-    temp.previousMillis = millis();   
+    temp.previousMillis += temp.interval ;
 
     // if the LED is off turn it on and vice-versa:
     temp.ledState = !temp.ledState ; // Inverti il LED