更改 Config.h 文件,添加一行

 #define UART0_AS_SBUS

这样设备就会将 UART0 用作 SBUS(波特率 1M)

在 main.cpp 的 loop() 函数中有 S.BUS 例程,编辑这个例程来适配你的遥控器数值区间

#ifdef UART0_AS_SBUS
  if (sbus.Read()) {
    /* Grab the received data */
    sbusData = sbus.data();
    /* Display the received data */
    for (int8_t i = 0; i < sbusData.NUM_CH; i++) {
      Serial.print(sbusData.ch[i]);
      Serial.print("\\t");
    }
    /* Display lost frames and failsafe data */
    Serial.print(sbusData.lost_frame);
    Serial.print("\\t");
    Serial.println(sbusData.failsafe);

    float speed_limit = 1.0;
    if (sbusData.ch[4] < 300) {
      speed_limit = 0.33;
    } else if (sbusData.ch[4] == 1002) {
      speed_limit = 0.66;
    } else if (sbusData.ch[4] > 1700) {
      speed_limit = 1.0;
    }

    float speed_input = constrain(float(sbusData.ch[2] - SBUS_MID)/SBUS_RAN, -1.0, 1.0);
    float turn_input = - constrain(float(sbusData.ch[3] - SBUS_MID)/SBUS_RAN, -1.0, 1.0);

    float left_speed = (speed_input) * speed_limit * 6000.0 - (turn_input * 0.33 * 6000.0);
    float right_speed = (speed_input) * speed_limit * 6000.0 + (turn_input * 0.33 * 6000.0);

    jointsCtrl.hubMotorCtrl(left_speed, (right_speed), right_speed, left_speed);
  }
#endif

编译后将程序上传至驱动板

合成 1 (0-00-00-00).png

接线: