4 Introdotto un argomento per la funzione che nodifica l'intervallo di lampeggio
9 int ledA = 13; // the number of the LED pin
10 // Variables will change:
11 int ledStateA = LOW; // ledState used to set the LED
12 long previousMillisA = 0; // will store last time LED was updated
15 int ledB = 12; //Secondo LED
16 int ledStateB = LOW; // ledState used to set the LED
17 long previousMillisB = 0; // will store last time LED was updated
20 // set the digital pin as output:
21 pinMode(ledA, OUTPUT);
22 pinMode(ledB, OUTPUT);
34 void lightLedA (int interval) {
35 // Illumina il ledA secondo un intervallo passato come argomento
37 if (millis() > previousMillisA + interval) {
38 // save the last time you blinked the LED
39 previousMillisA = millis();
41 // if the LED is off turn it on and vice-versa:
46 // set the LED with the ledState of the variable:
47 digitalWrite(ledA, ledStateA);
52 void lightLedB (int interval) {
53 // Illumina il ledB secondo un intervallo passato come argomento
55 if (millis() > previousMillisB + interval) {
56 // save the last time you blinked the LED
57 previousMillisB = millis();
59 // if the LED is off turn it on and vice-versa:
64 // set the LED with the ledState of the variable:
65 digitalWrite(ledB, ledStateB);
70 - Quali similitudini ci sono tra le due funzioni?
71 - Distinguere i dati comuni tra le due funzioni che ci servono per
73 - Distinguere i dati che caratterizzano un LED rispetto all'altro
74 - Provare a integrare le variabili relative ai due LED dentro le
76 - Sarebbe possibile scrivere una funzione che possa interagire con un LED qualunque?
77 ES: Come inpostare il PIN del LED? Come gestire lo stato del LED?