1 // Funzioni personalizzate
2 // Un scheda e' un documento che viene concatenato allo sketch originale
5 // Blink con pausa lunga
7 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
8 delay(1000); // wait for a second
9 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
10 delay(1000); // wait for a second
14 // Blink con pausa breve
16 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
17 delay(200); // wait for a second
18 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
19 delay(1000); // wait for a second
22 void varia(int a = 300) { // Varia has a default value, the user can override it with an argument
23 // Lampeggia per un tempo impostato dall'utente,
24 // il default e' 300ms
26 digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
27 delay(a); // wait for a second
28 digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
29 delay(a); // wait for a second
33 void lampeggia(int ripetizioni) {
34 // Accende un LED per un numero stabilito di volte
36 // Questa funziona accetta un parametro: ripetizioni
38 while (i < ripetizioni) {
39 rapido(); // accende e spegne rapidamente il LED
40 i = i + 1 ; // incrementa l'iteratore
41 // i++ ; // equivalente
45 int area(int latoA, int latoB) {
46 // Calcola l'area di un rettangolo
47 // e ritorna il valore calcolato: questa funzione ha un valore di ritorno
48 // dichiarato come int
50 return(latoA * latoB);