Edge AI開發平台比一比
|
   

#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
String data = "";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
mySerial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
while (mySerial.available()){ //Check if there is an available byte to read,
delay(10); //Delay added to make thing stable
char c = mySerial.read(); //Conduct a serial read
if (c == '\n') {break;} //Exit the loop when the "" is detected after the word
data += c; //Shorthand for data = data + c
}

if (data.length() > 0) { // 判斷data內有值在更換
data.trim();
delay(100);
Serial.println(data);
}
data = "";

while (Serial.available()){ //Check if there is an available byte to read,
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == '\n') {break;} //Exit the loop when the "" is detected after the word
data += c; //Shorthand for data = data + c
}

if (data.length() > 0) { // 判斷data內有值在更換
data.trim();
delay(100);
// Serial.println(data);
mySerial.println(data);
}
data = "";
}
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8, 9);
String data = "";
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
mySerial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
while (mySerial.available()){ //Check if there is an available byte to read,
delay(10); //Delay added to make thing stable
char c = mySerial.read(); //Conduct a serial read
if (c == '\n') {break;} //Exit the loop when the "" is detected after the word
data += c; //Shorthand for data = data + c
}

if (data.length() > 0) { // 判斷data內有值在更換
data.trim();
delay(100);
Serial.println(data);
}
data = "";

while (Serial.available()){ //Check if there is an available byte to read,
delay(10); //Delay added to make thing stable
char c = Serial.read(); //Conduct a serial read
if (c == '\n') {break;} //Exit the loop when the "" is detected after the word
data += c; //Shorthand for data = data + c
}

if (data.length() > 0) { // 判斷data內有值在更換
data.trim();
delay(100);
// Serial.println(data);
mySerial.println(data);
}
data = "";

}
xelalee
Latest posts by xelalee (see all)

    訂閱MakerPRO知識充電報

    與40000位開發者一同掌握科技創新的技術資訊!

    Author: xelalee

    Share This Post On
    468 ad

    Submit a Comment

    發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *