UIFlow Guide
Control multiple servos to rotate at specific angles every second in a loop. You can continue to add more servos if needed.
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:
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)
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)