当前位置:网站首页>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) 来设定了。
边栏推荐
- Upgrade CentOS php7.2.24 to php7.3
- 深度学习参数初始化(一)Xavier初始化 含代码
- C code production YUV420 planar format file
- II. D3.js draw a simple figure -- circle
- docker建立mysql:5.7版本指定路径挂载不上。
- Specified interval inversion in the linked list
- Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
- GStreamer ffmpeg avdec decoded data flow analysis
- Laravel框架 踩坑(一)
- Reading notes of "learn to ask questions"
猜你喜欢

Inno Setup 制作安装包

Interview questions about producers and consumers (important)

On the practice of performance optimization and stability guarantee

SecureCRT password to cancel session recording

7.2 brush two questions

Pits encountered in the use of El checkbox group

Basic components and intermediate components

691. 立方体IV

Inno setup production and installation package

Final, override, polymorphism, abstraction, interface
随机推荐
LeetCode
Advanced API (byte stream & buffer stream)
Winter vacation work of software engineering practice
Laravel Web Framework
centos php7.2.24升级到php7.3
Common analysis with criteria method
II. D3.js draw a simple figure -- circle
【已解决】win10找不到本地组策略编辑器解决方法
Distributed lock
2021 year end summary
Advanced APL (realize group chat room)
[attribute comparison] defer and async
Basic knowledge about SQL database
Thoughts in Starbucks
Hash table, generic
dataworks自定义函数开发环境搭建
TypeScript let與var的區別
PHP install composer
Chrome 98 Private Network Access problem w/ disabled web security: Request had no target IP address
多个全局异常处理类,怎么规定执行顺序