]> git.piffa.net Git - sketchbook_andrea/blob - basic/blinks/blink_2_funzioni/blink_2_funzioni.ino
Numerati bliks
[sketchbook_andrea] / basic / blinks / blink_2_funzioni / blink_2_funzioni.ino
1 /*
2   Blink v2
3  
4  Accensione e spegnimanto di un LED utilizzando funzioni
5  per comandare il lampeggio.
6  
7  This example code is in the public domain.
8  */
9
10 // Pin 13 has an LED connected on most Arduino boards.
11 // give it a name:
12 int led = 13;
13 int breve = 200;  // Variabile richiambile nel corso dell'esecuzione
14 int lunga = 1000;
15
16 // the setup routine runs once when you press reset:
17 void setup() {                
18   // initialize the digital pin as an output.
19   pinMode(led, OUTPUT);     
20 }
21
22 // the loop routine runs over and over again forever:
23 void loop() {
24   rapido(); // accende e spegne rapidamente il LED
25   rapido(); // accende e spegne rapidamente il LED
26   lento();  // accende e spegne lentamente il LED
27 }
28
29 // Funzioni create dall'utente:
30
31 void rapido() {
32   // Accende e spegne rapidamente il LED
33
34   // sequenze di istruzione: accendere e spegnere il LED
35   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
36   delay(breve);               // wait for a second
37   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
38   delay(breve);               // wait for a second
39 }
40
41 void lento() {  
42   // Accende e spegne lentamente il LED
43
44   // sequenze di istruzione: accendere e spegnere il LED
45   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
46   delay(lunga);               // wait for a second
47   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
48   delay(lunga); 
49 }
50
51
52