]> git.piffa.net Git - sketchbook_andrea/blob - serial/comm_tx/comm_tx.ino
2afb4e73f6cce2b5b09bbc23f63a5d13220d841e
[sketchbook_andrea] / serial / comm_tx / comm_tx.ino
1 /*
2   Analog comm: TX
3  
4  Comunicazione seriale 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 // Prima scheda: input
12 int led = 13;  // Debug
13 int input = 2;  // Questa e' la scheda con un input
14 int TX = 3 ; // Pin di trasmissione
15
16 void setup() {                
17   // initialize the digital pin as an output.
18   pinMode(led, OUTPUT);       // Il PIN e' attivato come output per DEBUG
19   pinMode(TX, OUTPUT);       // Il PIN e' attivato come output
20   pinMode(input, INPUT);        // Il PIN e' attivato come output
21 }
22
23 // the loop routine runs over and over again forever:
24 void loop() {
25   if (digitalRead(input) == HIGH) { // Verifica se il PIN input e' +5v
26     digitalWrite(led, HIGH); // Debug
27     digitalWrite(TX, HIGH);
28     delay(50);
29   } 
30   else { // Alterativa: se non e' +5v
31     digitalWrite(led, LOW);
32     digitalWrite(TX, LOW);
33     delay(50);
34   }
35 }
36
37
38
39