mirror of
https://github.com/esp8266/Arduino.git
synced 2025-08-01 03:47:23 +03:00
.settings
app
arduino-builder
arduino-core
build
cmd
javadoc
linux
macosx
shared
examples
01.Basics
02.Digital
03.Analog
04.Communication
ASCIITable
Dimmer
Graph
Midi
MultiSerialMega
MultiSerialMega.ino
PhysicalPixel
ReadASCIIString
SerialCallResponse
SerialCallResponseASCII
SerialEvent
VirtualColorMixer
05.Control
06.Sensors
07.Display
08.Strings
09.USB
10.StarterKit
ArduinoISP
icons
lib
tools
manpage.adoc
reference.zip
revisions.txt
windows
build.xml
build_pull_request.bash
create_reference.pl
fetch.sh
howto.txt
libastylej-2.05.zip.sha
hardware
libraries
.classpath
.gitignore
.project
README.md
format.every.sketch.sh
license.txt
41 lines
803 B
C++
41 lines
803 B
C++
/*
|
|
Mega 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 on the Arduino Mega
|
|
|
|
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
|
|
|
|
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);
|
|
}
|
|
}
|