]> git.piffa.net Git - sketchbook_andrea/blob - basic/blink_sviluppo/blink_3_variables_two_led_functions/blink_3_variables_two_led_functions.ino
Blink sviluppo.
[sketchbook_andrea] / basic / blink_sviluppo / blink_3_variables_two_led_functions / blink_3_variables_two_led_functions.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 red = 12;
13 int breve = 200;
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   pinMode(red, OUTPUT);
21 }
22
23 // the loop routine runs over and over again forever:
24 void loop() {
25 lightRed();
26 lightGreen();
27 }
28
29 void lightRed() {
30   digitalWrite(red, HIGH);   // turn the LED on (HIGH is the voltage level)
31   delay(lunga);               // wait for a second
32   digitalWrite(red, LOW);    // turn the LED off by making the voltage LOW
33   delay(lunga); 
34 }
35
36 void lightGreen() {
37   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
38   delay(breve);               // wait for a second
39   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
40   delay(breve);               // wait for a second
41 }
42