]> git.piffa.net Git - sketchbook_andrea/blob - basic/blinks/blink_5_funzioni/blink_5_funzioni.ino
Arduino base ottobre
[sketchbook_andrea] / basic / blinks / blink_5_funzioni / blink_5_funzioni.ino
1 /*
2   Blink v6
3  
4  Due LEDs con funzioni.
5  
6  */
7
8 // Pin 13 has an LED connected on most Arduino boards.
9 // give it a name:
10 int led = 13;
11 int red = 12;
12 int breve = 200;
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   pinMode(red, OUTPUT);
20 }
21
22 // the loop routine runs over and over again forever:
23 void loop() {
24   lightRed();
25   lightGreen();
26 }
27
28 void lightRed() {
29   digitalWrite(red, HIGH);   // turn the LED on (HIGH is the voltage level)
30   delay(lunga);               // wait for a second
31   digitalWrite(red, LOW);    // turn the LED off by making the voltage LOW
32   delay(lunga); 
33 }
34
35 void lightGreen() {
36   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
37   delay(breve);               // wait for a second
38   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
39   delay(breve);               // wait for a second
40 }
41
42