舵机扩展模块

python 编程:

创建实例

  • servo_ex(port_x)
    创建servo_ex实例,port_x 可取值为 thunbot.PORT_1,thunbot.PORT_2,thunbot.PORT_3,thunbot.PORT_4,thunbot.PORT_A,thunbot.PORT_B

方法

  • turn_percent(type, value)
    控制舵机转动百分比,type 可取 0x01(扩展舵机1), 0x02(扩展舵机2), 0x04(扩展舵机3), 0x08(扩展舵机4),可以按位或操作。 value值依次为对应舵机的值。

  • percent_set(max, min, zero)
    设置舵机位置,分别指定最大位置max,最小位置min,零点位置zero 。

编程示范

import thunbot
import time

c1 = thunbot.servo_ex(thunbot.PORT_A)
c1.percent_set(0x01, -100, 0, -50)
while True:
  print("-100")
  c1.turn_percent(0x0F, -100, -100, -100, -100)
  time.sleep(3)
  print("0")
  c1.turn_percent(0x0F, 0, 0, 0, 0)
  time.sleep(3)
  print("-100")
  c1.turn_percent(0x0F, 100, 100, 100, 100)
  time.sleep(3)

results matching ""

    No results matching ""