嵌入式 - Arduino的串口操作

使用SoftwareSerial Library,可以在digital pin上进行串行通讯。可同时定义多个软件串口,多个串口的话最高速度115200bps。

要使用这个库,需要包含头文件:

#include <SoftwareSerial.h>

这个库的局限:

1,不能同时收发数据

2,定义了多个串口的话,同一时间只能一个串口接收数据。

3,On Arduino or Genuino 101 boards the current maximum RX speed is 57600bps.

定义多个串口对象实例,同一时间只能激活一个。

可用方法

1,创建对象

SoftwareSerial(rxPin, txPin, inverse_logic);

Parameters
rxPin: the pin on which to receive serial data.
txPin: the pin on which to transmit serial data.
inverse_logic: used to invert the sense of incoming bits (the default is normal logic). If set, SoftwareSerial treats a LOW (0v on the pin, normally) on the RX pin as a 1-bit (the idle state) and a HIGH (5V on the pin, normally) as a 0-bit. It also affects the way that it writes to the TX pi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值