參考資訊:
https://gist.github.com/maxpromer/1742289fc3175df454c99230d3597830
Serial:用於跟電腦溝通使用
Serial1:用於硬體UART使用
#define RXD1 9 #define TXD1 10 void setup() { // initialize serial communication at 9600 bits per second Serial.begin(9600); // initialize UART with baud rate of 9600 Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1); } void loop() { while (Serial1.available()){ char ch = Serial1.read(); Serial.write(ch); } }