5 Accensione e spegnimanto di un LED utilizzando un pin come input.
7 Schemi del circuito per bottone in pull down:
8 - http://lab.piffa.net/schemi/button_1_bb.png
9 - http://lab.piffa.net/schemi/button_1_schem.png
15 // the setup routine runs once when you press reset:
17 pinMode(led, OUTPUT); // Il PIN e' attivato come output
18 pinMode(input, INPUT); // Il PIN e' attivato come output
20 Serial.begin(9600); // Attivazione seriale
23 // the loop routine runs over and over again forever:
25 if (digitalRead(input) == HIGH) { // Verifica se il PIN input e' +5v
26 digitalWrite(led, HIGH);
27 Serial.println("Bottone premuto: circuito chiuso"); // Debug seriale
30 else { // Alterativa: se non e' +5v
31 digitalWrite(led, LOW);
32 Serial.println("Bottone libero: circuito aperto"); // Debug seriale
38 // 1. invertire il programma facendo in modo che il led si spenga
39 // quando il bottone e' premuto. Consoderare come ottenere lo stesso risultato
40 // modificando il circuito.
41 // 2. Modificare il programma per far brillare il led cinque volte al secondo
42 // quando il bottone e' premuto.
44 // Domanda: cosa succede se il jumper input non e' collegato ne al +5 ne al gound?