首页 > 解决方案 > 串口软件无法读写数据

问题描述

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

   #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());
 }

请你们中的任何人帮助我。提前致谢

标签: arduino

解决方案


推荐阅读