跳转到内容

Grove TB6612FNG 电机驱动

Grove TBB6612FNG 通过 I²C 总线运行,具备控制直流电机和步进电机的能力。 在当前实现阶段,仅实现了直流电机。

# Example configuration
grove_tb6612fng:
- address: 0x14
id: test_motor
  • id(必选,ID):用于此 TB6612FNG 组件的 ID。
  • address(可选,int):驱动器的 I²C 地址。 默认值为 0x14。

.. grove_tb6612fng.run:

通过定义旋转方向和速度使电机转动,速度范围为 0 到 255。

on_...:
then:
- grove_tb6612fng.run:
channel: 1
speed: 255
direction: BACKWARD
id: test_motor

.. grove_tb6612fng.stop:

使电机停止运动,但如果存在外力拉拽则不会停止转动;如果你的情况属于此类,应使用刹车操作。

on_...:
then:
- grove_tb6612fng.stop:
channel: 1

.. grove_tb6612fng.break:

将电机通道设为刹车模式,确保即使在外力推动或拉动下轮子也不会转动。

on_...:
then:
- grove_tb6612fng.break:
channel: 1
id: test_motor

.. grove_tb6612fng.standby:

当板子长时间未使用时,将其设为待机状态,以减少功耗并避免静止时的抖动。

on_...:
then:
- grove_tb6612fng.standby
id: test_motor

.. grove_tb6612fng.no_standby:

使板子处于唤醒状态。每次重启 ESPHome 时,默认模式均设为待机,以确保电机不会意外转动。

on_...:
then:
- grove_tb6612fng.no_standby
id: test_motor

.. grove_tb6612fng.change_address:

如果需要同时连接多个板子,可以通过此操作更改地址。地址可更改为 0x01 - 0x7f 范围内的值(含端点值)。

on_...:
then:
- grove_tb6612fng.change_address:
address: 0x15
id: test_motor