]> git.piffa.net Git - sketchbook_andrea/blobdiff - multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino
clean up
[sketchbook_andrea] / multitasking / BlinkWithoutDelay_7_struct / BlinkWithoutDelay_7_struct.ino
index 621083ede47f4896e2b9d56789892295fb34ccbf..e72666285569423af9762ee8e6c6b2cc2966c32c 100644 (file)
@@ -21,13 +21,13 @@ blinkLed ledB = {
   12, LOW, 500, 0};
 
 void setup() {
-  pinMode(ledA.ledPin, OUTPUT);
+  pinMode(ledA.ledPin, OUTPUT); // Domanda: integrare l'impostazione del LED nel codice della funzione.
   pinMode(ledB.ledPin, OUTPUT);
 }
 
 void loop()
 {
- ledA = lightLed(ledA );
+ ledA = lightLed(ledA ); // Aggiorna lo stato del LED in base all'esecuzione della funzione
  ledB = lightLed(ledB );
 }
 
@@ -37,7 +37,7 @@ 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();