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