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 += interval;
41 // if the LED is off turn it on and vice-versa:
42 ledStateA = !ledStateA;
43 // set the LED with the ledState of the variable:
44 digitalWrite(ledA, ledStateA);
49 void lightLedB (int interval) {
50 // Illumina il ledB secondo un intervallo passato come argomento
52 if (millis() - previousMillisB >= interval) {
53 // save the last time you blinked the LED
54 previousMillisB += interval;
56 // if the LED is off turn it on and vice-versa:
57 ledStateB = !ledStateB;
58 // set the LED with the ledState of the variable:
59 digitalWrite(ledB, ledStateB);
64 - Quali similitudini ci sono tra le due funzioni?
65 - Distinguere i dati comuni tra le due funzioni che ci servono per
67 - Distinguere i dati che caratterizzano un LED rispetto all'altro
68 - Provare a integrare le variabili relative ai due LED dentro le
70 - Sarebbe possibile scrivere una funzione che possa interagire con un LED qualunque?
71 ES: Come inpostare il PIN del LED? Come gestire lo stato del LED?