]> git.piffa.net Git - sketchbook_andrea/blob - serial/comm_rx/comm_rx.ino
Buttons and serial
[sketchbook_andrea] / serial / comm_rx / comm_rx.ino
1 /*
2   Analog comm: RX
3  
4  Comunicazione analogica tra due schede arduino.
5  La prima scheda ha un bottone come input e 
6  comunica con un altra scheda che monta un LED come output.
7  Il led della seconda si accende quando rileva
8  la pressione del bottone della prima.
9  */
10
11 // Seconda scheda: output
12 int led  = 13; // Questa scheda ha spolo l'output
13 int RX   = 3 ; // Pin di ricezione
14
15 void setup() {                
16   // initialize the digital pin as an output.
17   pinMode(led, OUTPUT);       // Il PIN e' attivato come output
18   pinMode(RX, 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(RX) == 1) { // Verifica se il PIN input e' +5v
24     digitalWrite(led, HIGH);
25     delay(50);
26   } 
27   else if (digitalRead(RX) == 0) { // Alterativa: se non e' +5v
28     digitalWrite(led, LOW);
29     delay(50);
30   }
31 }
32