Ameba Arduino IDE V1.0.4 目前要用D0/D1的UART 時需

#include <SoftwareSerial.h>

並宣告: D0:RX,D1:TX 為 SofewareSerial

SoftwareSerial mySerial(0, 1); // RX, TX

將 D0/D1 RX/TX 的UART 改為Hardware Serial
並命名為: Serial1   (Serial monitor console 為 Serial)
與Arduino 相容。

參考標準Arduino Examle : Multple Serial.ino

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:

void loop() {
// read from port 1, send to port 0:
if (Serial1.available()) {
int inByte = Serial1.read();

// read from port 0, send to port 1:
if (Serial.available()) {
int inByte = Serial.read();

williamlai 回答了