当前位置:网站首页>Arduino 软串口通信 的几点体会
Arduino 软串口通信 的几点体会
2022-07-03 07:16:00 【yuchu3d】
1、arduino主板上的 RX TX 引脚 有时不一定够用,这时就需要将别的 引脚 通过软件 模拟成串口通信引脚,但不是每个引脚 都能这么转换,不同的板子,有所不同。
2、arduino Uno 上只有一个 RX TX 引脚,分别是 0和1 引脚,这两个引脚通常是默认与电脑之间进行通信用的,Serial.begin Serial.print Serial.read 针对的都是这个引脚。 如果 arduino Uno需要和别的硬件进行串口通信,就必须 设定软串口,将别的引脚 拿来当作串口通信引脚来使用。首先 就要 包含相应的库函数 SoftwareSerial.h , 然后 用 SoftwareSerial name(rxPin, txPin) 来定义一个软串口 name, 并且 还要用 name.listen(),来监听这个软串口。 当然 也不是任意的引脚都能做串口通信引脚(引脚需要支持中断功能)。
3、如果原本 arduino的板子上 就有 不止一个 TX RX引脚,有时 就可以直接用 板子上的 TX RX引脚。以 arduino mega 2560来说,其上 有 RX0 TX0, RX1 TX1,RX2 TX2,RX3 TX3 四对串口引脚, RX0 TX0 , 是默认与电脑通信的, 用serial 设置, 和其他板子通信时,如果是接在 RX1 TX1 上,我们用 serial1 来设置,同理 接在 RX2 TX2 上,我们用 serial2 来设置, 而不需要用 SoftwareSerial 来设置软串口,也不用 listen()函数来监听。 但是 我们如果用的是其他引脚 比如 10 11 来做串口通信,就要用 SoftwareSerial name(rxPin, txPin) 来设定了。
边栏推荐
- 《指環王:力量之戒》新劇照 力量之戒鑄造者亮相
- 带你全流程,全方位的了解属于测试的软件事故
- C代码生产YUV420 planar格式文件
- Laravel框架 踩坑(一)
- Store WordPress media content on 4everland to complete decentralized storage
- Architecture notes
- [most detailed] latest and complete redis interview book (50)
- 7.2刷题两个
- Operation and maintenance technical support personnel have hardware maintenance experience in Hong Kong
- 【最详细】最新最全Redis面试大全(50道)
猜你喜欢
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
Flask Foundation
带你全流程,全方位的了解属于测试的软件事故
Sorting out the core ideas of the pyramid principle
Distributed transactions
JMeter test result output
Software testing learning - the next day
Inno Setup 制作安装包
On the practice of performance optimization and stability guarantee
Software testing learning - day 3
随机推荐
1. E-commerce tool cefsharp autojs MySQL Alibaba cloud react C RPA automated script, open source log
php artisan
Distributed lock
MySQL syntax (basic)
691. 立方体IV
[day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
centos php7.3安装redis扩展
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Sorting out the core ideas of the pyramid principle
Interview questions about producers and consumers (important)
PHP install composer
Practice of enterprise ab/testing platform
Hash table, generic
LeetCode
Arctic code vault contributor
php安装composer
Common analysis with criteria method
Resthighlevelclient gets the mapping of an index
Architecture notes
Selenium key knowledge explanation