]> git.piffa.net Git - sketchbook_andrea/blob - basic/blinks/blink_5_2_leds/blink_5_2_leds.ino
Arduino base ottobre
[sketchbook_andrea] / basic / blinks / blink_5_2_leds / blink_5_2_leds.ino
1 /*
2   Blink v5
3  
4  Accensione e spegnimanto di 2 LED.
5  Nel circuito oltre al LED montato direttamente sul pin 13
6  viene aggiunto un altro LED pilotato dal PIN 12.
7  
8  Ricordarsi di usare una resistenza da ~320ohms per il secondo LED.
9  Resistenza = (Voltaggio_Arduino - Forward_voltage_LED) / (ampere utilizzati)
10  R = (5v-1.8v) / 0.010a 
11  R =320ohms
12  
13
14  Schema: http://lab.piffa.net/schemi/led_single_bb.png
15  - http://lab.piffa.net/schemi/led_single_schem.png
16
17   This example code is in the public domain.
18  */
19
20 // Pin 13 has an LED connected on most Arduino boards.
21 // give it a name:
22 int led = 13;
23 int red = 12; // Definiamo un altro led
24 int breve = 200;  // Variabile richiambile nel corso dell'esecuzione
25 int lunga = 1000;
26
27 // the setup routine runs once when you press reset:
28 void setup() {                
29   // initialize the digital pin as an output.
30   pinMode(led, OUTPUT); // Abilitaiamo entrambi i LED     
31   pinMode(red, OUTPUT);
32 }
33
34 // the loop routine runs over and over again forever:
35 void loop() {
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   digitalWrite(red, HIGH);   // turn the LED on (HIGH is the voltage level)
42   delay(lunga);               // wait for a second
43   digitalWrite(red, LOW);    // turn the LED off by making the voltage LOW
44   delay(lunga); 
45 }
46
47