库函数下载链接https://download.csdn.net/download/qq_40925542/87207281
该库函数适用于具有多个串口的开发板,esp32中测试通过,测试代码如下:
#include "SBUS.h"
SBUS x8r(Serial2);
// channel, fail safe, and lost frames data
uint16_t channels[16];
bool failSafe;
bool lostFrame;
void setup()
{
// begin the SBUS communication
x8r.begin();
Serial2.begin(100000, SERIAL_8E2, 16, 17);
Serial.begin(115200);
}
void loop()
{
// look for a good SBUS packet from the receiver
if (x8r.read(&channels[0], &failSafe, &lostFrame))
{
// write the SBUS packet to an SBUS compatible servo
for (int i = 0; i < 16; i++)
{
Serial.print(channels[i]);
Serial.print(" ");
}
Serial.println();
}
}
注意:SBUS的通信频率100000,数据为8位,偶校验。
在电路连接前必须进行外部电路取反:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)