File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed 
build/shared/examples/04.Communication/MultiSerial Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ /* 
2+   Multple Serial test 
3+ 
4+  Receives from the main serial port, sends to the others. 
5+  Receives from serial port 1, sends to the main serial (Serial 0). 
6+ 
7+  This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc 
8+ 
9+  The circuit: 
10+  * Any serial device attached to Serial port 1 
11+  * Serial monitor open on Serial port 0: 
12+ 
13+  created 30 Dec. 2008 
14+  modified 20 May 2012 
15+  by Tom Igoe & Jed Roach 
16+  modified 27 Nov 2015 
17+  by Arturo Guadalupi 
18+ 
19+  This example code is in the public domain. 
20+ 
21+  */  
22+ 
23+ 
24+ void  setup () {
25+   //  initialize both serial ports:
26+   Serial.begin (9600 );
27+   Serial1.begin (9600 );
28+ }
29+ 
30+ void  loop () {
31+   //  read from port 1, send to port 0:
32+   if  (Serial1.available ()) {
33+     int  inByte = Serial1.read ();
34+     Serial.write (inByte);
35+   }
36+ 
37+   //  read from port 0, send to port 1:
38+   if  (Serial.available ()) {
39+     int  inByte = Serial.read ();
40+     Serial1.write (inByte);
41+   }
42+ }
Original file line number Diff line number Diff line change 1+ Use two of the serial ports available on the Arduino board.
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments