Arduino串口的hello world
串口收发的简单栗子
String str = "";
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() {
while (Serial.available() > 0)
{
str += char(Serial.read());
delay(2);
}
if (str.length() > 0)
{
delay(200);
str="R:"+str;
Serial.println(str);
}
delay(10);
str = "";
}
参考资料:
https://www.lxx1.com/3905