1 /* Blink without Delay - Pulizia
3 Semplificato il ciclo condizionale
6 // constants won't change. Used here to
10 int ledA = 13; // the number of the LED pin
11 // Variables will change:
12 int ledStateA = LOW; // ledState used to set the LED
13 long previousMillisA = 0; // will store last time LED was updated
16 int ledB = 12; //Secondo LED
17 int ledStateB = LOW; // ledState used to set the LED
18 long previousMillisB = 0; // will store last time LED was updated
21 // set the digital pin as output:
22 pinMode(ledA, OUTPUT);
23 pinMode(ledB, OUTPUT);
35 void lightLedA (int interval) {
36 // Illumina il ledA secondo un intervallo passato come argomento
38 if(millis() - previousMillisA > interval) {
39 // save the last time you blinked the LED
40 previousMillisA = millis();
42 // if the LED is off turn it on and vice-versa:
43 ledStateA = !ledStateA ; // Inverti il LED
45 digitalWrite(ledA, ledStateA);
48 void lightLedB (int interval) {
49 // Illumina il ledB secondo un intervallo passato come argomento
51 if(millis() - previousMillisB > interval) {
52 // save the last time you blinked the LED
53 previousMillisB = millis();
55 // if the LED is off turn it on and vice-versa:
56 ledStateB = !ledStateB ; // Inverti il LED
58 digitalWrite(ledB, ledStateB);
61 1. E' possibile avere una sola funzione che permetta di gestire
62 qualunque LED io voglia aggiungere?
65 - integrazione tra funzioni e dati: programmazione a oggetti
66 - Uso di pointers per modificare dati esterni allo scope della funzione, static
67 - Uso di forme di dati strutturate (array, struct) per scambiare dati tra funzioni e programma