UIFlow Guide
控制多个舵机循环每隔一秒转动一个角度,你可以继续添加舵机数量
from m5stack import *
from m5ui import *
from uiflow import *
import time
import hat
setScreenColor(0x111111)
hat_servos_1 = hat.get(hat.SERVOS)
hat_8servos_2.set_pwr_ctrl(1)
while True:
.write_servo_angle(1,0)
hat_8servos_2.write_servo_angle(2,0)
hat_8servos_2.write_servo_angle(3,0)
hat_8servos_2.write_servo_angle(4,0)
wait(1)
hat_8servos_2.write_servo_angle(1,90)
hat_8servos_2.write_servo_angle(2,90)
hat_8servos_2.write_servo_angle(3,90)
hat_8servos_2.write_servo_angle(4,90)
wait(1)
hat_8servos_2.write_servo_angle(1,180)
hat_8servos_2.write_servo_angle(2,180)
hat_8servos_2.write_servo_angle(3,180)
hat_8servos_2.write_servo_angle(4,180)
wait(1)
hat_8servos_2.write_servo_angle(1,90)
hat_8servos_2.write_servo_angle(2,90)
hat_8servos_2.write_servo_angle(3,90)
hat_8servos_2.write_servo_angle(4,90)
wait(1)
hat_8servos_2.write_servo_angle(1,0)
hat_8servos_2.write_servo_angle(2,0)
hat_8servos_2.write_servo_angle(3,0)
hat_8servos_2.write_servo_angle(4,0)
wait(1)
wait_ms(2)
hat_8servos_1.get_pwr_ctrl()
hat_8servos_1.read_servo_angle(1)
hat_8servos_1.read_servo_pulse(1)
hat_8servos_1.set_pwr_ctrl(1)
hat_8servos_1.write_servo_angle(1,0)
hat_8servos_1.write_servo_pulse(1,500)