]> git.piffa.net Git - sketchbook_andrea/blob - basic/blinks/blink_3_funzioni_argomenti/blink_3_funzioni_argomenti.ino
f4b603b5d0fc3e21cc5a8f6dde3cf9cc6cc78364
[sketchbook_andrea] / basic / blinks / blink_3_funzioni_argomenti / blink_3_funzioni_argomenti.ino
1
2 // ////////////
3 // Commento iniziale
4 /*
5   Blink v2
6  
7  Accensione e spegnimanto di un LED utilizzando funzioni
8  per comandare il lampeggio.
9  
10  This example code is in the public domain.
11  */
12 // //////////////
13 // Dichiarazione variabili
14
15 // Pin 13 has an LED connected on most Arduino boards.
16 // give it a name:
17 int led = 13;
18 // Le variabili lunga e breve non sono piu' necessarie
19
20 // /////////////////
21 // Setup
22 void setup() {                
23   // initialize the digital pin as an output.
24   pinMode(led, OUTPUT);     
25 }
26
27 // ///////////////
28 // loop
29 void loop() {
30   brilla(300);
31   brilla(300);
32   brilla(600);
33 }
34
35 // ///////////////
36 // Funzioni create dall'utente:
37
38 void brilla(int velocita) {
39   // Accende e spegne il LED accetando un argomento 
40   // per impostare la velocita'.
41
42   // sequenze di istruzione: accendere e spegnere il LED
43   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
44   delay(velocita);               // wait for a second
45   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
46   delay(velocita);               // wait for a second
47 }
48
49
50
51 /* Domande:
52  *  1. Come si potrebbe fare per poter utilizzare la funzione brilla
53  *   con PIN diversi rispetto a LED?
54  *  
55  *  2. Le dichiarazioni delle variabili breve e lunga possono essere
56  *  accorpate nelle rispettive funzioni?
57  *  
58  *  Esercizi sucessivi sulle funzioni: blink_5 e 6
59  */
60  
61  */