]> git.piffa.net Git - sketchbook_andrea/blobdiff - multitasking/BlinkWithoutDelay_2_led_cleanup/BlinkWithoutDelay_2_led_cleanup.ino
Multitasking
[sketchbook_andrea] / multitasking / BlinkWithoutDelay_2_led_cleanup / BlinkWithoutDelay_2_led_cleanup.ino
index 21c26eb05a20801b864cba50765bc314e25e9e86..7f338a93e9763f3de03997d17ac21135e2a2d109 100644 (file)
@@ -14,7 +14,7 @@
  by David A. Mellis
  modified 8 Feb 2010
  by Paul Stoffregen
- modified by eaman
+ modified by Andrea Manni
  
  This example code is in the public domain.
  
@@ -48,9 +48,9 @@ void setup() {
 void loop()
 {
 // Primo LED
-  if (millis() - previousMillisA > intervalA) {
-    // save the last time you blinked the LED 
-    previousMillisA = millis();   
+  if (millis() - previousMillisA >= intervalA) {
+    // Timestamp + timestamp = delta temporale
+    previousMillisA += intervalA ;
 
     // if the LED is off turn it on and vice-versa:
      ledStateA = !ledStateA;
@@ -59,9 +59,9 @@ void loop()
   }
   
 // Secondo LED: contratta
-    if (millis() - previousMillisB > intervalB) {
+    if (millis() - previousMillisB >= intervalB) {
     digitalWrite(ledB, !digitalRead(ledB));
-    previousMillisB = millis();   
+    previousMillisB += intervalB ;
   }
 }