微處理器 - Nordic Semiconductor nRF52840 (Arduino Nano 33 BLE) - 如何使用Serial



參考資訊:
https://docs.arduino.cc/tutorials/nano-33-ble-sense/uart/

Serial:用於跟電腦溝通使用
Serial1:用於硬體UART使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void setup() {
    // initialize serial communication at 9600 bits per second
    Serial.begin(9600);
 
    // initialize UART with baud rate of 9600
    Serial1.begin(9600);
}
 
void loop() {
    while (Serial1.available()){
        char ch = Serial1.read();
 
        Serial.write(ch);
    }
}

P.S. serialEvent1()目前尚無法使用