串行软件无法写入和读取数据

时间:2019-02-26 10:31:21

标签: arduino

我正在尝试将数据写入软件串行端口。但是我无法读取数据。 我使用了以下代码:

   #include<SoftwareSerial.h>
  SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
 // Open serial communications and wait for port to open:
 Serial.begin(57600);
 while (!Serial) {
 ; // wait for serial port to connect. Needed for Leonardo only
}


     Serial.println("Goodnight moon!");

 // set the data rate for the SoftwareSerial port
 mySerial.begin(57600);
 mySerial.println("Hello, world!");
 }

 void loop() // run over and over
 {
 if (mySerial.available())
 Serial.write(mySerial.read());
 if (Serial.available())
 mySerial.write(Serial.read());
 }

请任何人能帮助我。预先感谢

0 个答案:

没有答案