mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-13 10:29:35 +01:00
Modified example to not generate confusion
Only Arduino Mega was mentioned, but actually many boards have more than one Serial port
This commit is contained in:
parent
8e6a30e00c
commit
c009ac6e4c
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Multple Serial test
|
||||
|
||||
Receives from the main serial port, sends to the others.
|
||||
Receives from serial port 1, sends to the main serial (Serial 0).
|
||||
|
||||
This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc
|
||||
|
||||
The circuit:
|
||||
* Any serial device attached to Serial port 1
|
||||
* Serial monitor open on Serial port 0:
|
||||
|
||||
created 30 Dec. 2008
|
||||
modified 20 May 2012
|
||||
by Tom Igoe & Jed Roach
|
||||
modified 27 Nov 2015
|
||||
by Arturo Guadalupi
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void setup() {
|
||||
// initialize both serial ports:
|
||||
Serial.begin(9600);
|
||||
Serial1.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read from port 1, send to port 0:
|
||||
if (Serial1.available()) {
|
||||
int inByte = Serial1.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
|
||||
// read from port 0, send to port 1:
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Serial1.write(inByte);
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
Use two of the serial ports available on the Arduino board.
|
Loading…
x
Reference in New Issue
Block a user