简单的读写
此示例侦听通过串行连接进入的输入,然后将其重新发送回同一连接。
byte incomingBytes;
void setup() {
Serial.begin(9600); // Opens serial port, sets data rate to 9600 bps.
}
void loop() {
// Send data only when you receive data.
if (Serial.available() > 0) {
// Read the incoming bytes.
incomingBytes = Serial.read();
// Echo the data.
Serial.println(incomingBytes);
}
}