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());
}
请你们中的任何人帮助我。提前致谢
解决方案
推荐阅读
- python - 如何取消选择pydatatable中特定索引处的行?
- algorithm - 这个时间复杂度计算对吗?
- java - 您可以将装饰器添加到子类的父方法和变量吗?
- ios - 了解 Here Map iOS SDK 中的错误代码
- php - 在 PHP 中使用不同的访问令牌进行 API 调用
- json - 获取多个复选框值作为角度数组
- .net-core - 将 ServiceStack Redis 使用推送到 Application Insights 依赖项遥测
- mysql - 带有 sql 的 Nodejs
- python - 如何通过 django 视图调度 celery 任务
- json - (Django) 安装夹具“rules.json”时出现问题:“NoneType”对象没有属性“id”