5 3. Provare a isolare il codice per accendere ogni singolo led in una funzione:
6 Quali variabili determinano il comportamento del LED?
11 // constants won't change. Used here to
16 int ledA = 13; // the number of the LED pin
17 // Variables will change:
18 int ledStateA = LOW; // ledState used to set the LED
19 long previousMillisA = 0; // will store last time LED was updated
20 // the follow variables is a long because the time, measured in miliseconds,
21 // will quickly become a bigger number than can be stored in an int.
22 long intervalA = 1000; // interval at which to blink (milliseconds)
26 int ledB = 12; //Secondo LED
27 int ledStateB = LOW; // ledState used to set the LED
28 long previousMillisB = 0; // will store last time LED was updated
29 long intervalB = 500; // interval at which to blink (milliseconds)
33 // set the digital pin as output:
34 pinMode(ledA, OUTPUT);
35 pinMode(ledB, OUTPUT);
48 if(millis() - previousMillisA > intervalA) {
49 // save the last time you blinked the LED
50 previousMillisA = millis();
52 // if the LED is off turn it on and vice-versa:
57 // set the LED with the ledState of the variable:
58 digitalWrite(ledA, ledStateA);
64 if(millis() - previousMillisB > intervalB) {
65 // save the last time you blinked the LED
66 previousMillisB = millis();
68 // if the LED is off turn it on and vice-versa:
73 // set the LED with the ledState of the variable:
74 digitalWrite(ledB, ledStateB);
80 1. Modificare le funzioni in modo che accettino come parametro
81 l'intervallo di lampeggio.