X-Git-Url: http://git.piffa.net/web?a=blobdiff_plain;f=multitasking%2FBlinkWithoutDelay_7_struct%2FBlinkWithoutDelay_7_struct.ino;h=e72666285569423af9762ee8e6c6b2cc2966c32c;hb=cdfee5cfe2f5dd8cd7a8c61cfda797ed096d1d86;hp=621083ede47f4896e2b9d56789892295fb34ccbf;hpb=90f3116fa09ed583c137d1df423b9913f55522fa;p=sketchbook_andrea diff --git a/multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino b/multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino index 621083e..e726662 100644 --- a/multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino +++ b/multitasking/BlinkWithoutDelay_7_struct/BlinkWithoutDelay_7_struct.ino @@ -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();