]> git.piffa.net Git - sketchbook_andrea/blobdiff - multitasking/BlinkWithoutDelay_8_struct_pointer/BlinkWithoutDelay_8_struct_pointer.ino
Multitasking
[sketchbook_andrea] / multitasking / BlinkWithoutDelay_8_struct_pointer / BlinkWithoutDelay_8_struct_pointer.ino
index f038199e6d1743ff516441a5bc56ac83209e6f96..d5cd783706e526241d90a7f03aa4901f8c15db9b 100644 (file)
@@ -43,8 +43,8 @@ void loop()
 void lightLed(struct blinkLed *temp) { // temp ora e' un pointer e non una struttura autonoma: pass by reference (not by value)
   // Illumina il ledA secondo un intervallo passato come argomento
 
-  if(millis() - (*temp).previousMillis > (*temp).interval) { // l'operatore punto ha priorita' maggiore rispetto al pointer asterisco
-    (*temp).previousMillis = millis();   
+  if(millis() - (*temp).previousMillis >= (*temp).interval) { // l'operatore punto ha priorita' maggiore rispetto al pointer asterisco
+    (*temp).previousMillis += (*temp).interval ;
 
     // if the LED is off turn it on and vice-versa:
     temp->ledState = !temp->ledState ; // Forma contratta, deference operator: temp->ledState == (*temp).ledState