]> git.piffa.net Git - sketchbook_andrea/blob - basic/buttons/button_1/button_1.ino
buttons reordered
[sketchbook_andrea] / basic / buttons / button_1 / button_1.ino
1 /*
2   Input
3  
4  Accensione e spegnimanto di un LED utilizzando un pin come input.
5  
6
7  */
8
9 // Pin 13 has an LED connected on most Arduino boards.
10 // give it a name:
11 int led = 13;
12 int input = 8;
13
14 // the setup routine runs once when you press reset:
15 void setup() {                
16   // initialize the digital pin as an output.
17   pinMode(led, OUTPUT);       // Il PIN e' attivato come output
18   pinMode(input, INPUT);        // Il PIN e' attivato come output
19 }
20
21 // the loop routine runs over and over again forever:
22 void loop() {
23   if (digitalRead(input) == HIGH) { // Verifica se il PIN input e' +5v
24     digitalWrite(led, HIGH);
25   } 
26   else { // Alterativa: se non e' +5v
27     digitalWrite(led, LOW);
28   }
29 }
30
31
32 // Funzioni create dall'utente:
33
34