Serial User Guide for Arduino Boards | Seeed Studio Wiki
#
include
<SoftwareSerial.h>
SoftwareSerial
serialOne
(
2
,
3
)
;
SoftwareSerial
serialTwo
(
8
,
9
)
;
void
setup
(
)
{
Serial
.
begin
(
9600
)
;
while
(
!
Serial
)
{
}
serialOne
.
begin
(
9600
)
;
serialTwo
.
begin
(
9600
)
;
}
void
loop
(
)
{
serialOne
.
listen
(
)
;
Serial
.
println
(
"Data from port one:"
)
;
while
(
serialOne
.
available
(
)
>
0
)
{
char
inByte
=
serialOne
.
read
(
)
;
Serial
.
write
(
inByte
)
;
}
Serial
.
println
(
)
;
serialTwo
.
listen
(
)
;
Serial
.
println
(
"Data from port two:"
)
;
while
(
serialTwo
.
available
(
)
>
0
)
{
char
inByte
=
serialTwo
.
read
(
)
;
Serial
.
write
(
inByte
)
;
}
Serial
.
println
(
)
;
}