pdf-icon

UiFlow チュートリアル

UiFlow1 開発ガイド

プロジェクト管理

LTEネットワークを使用する

UiFlow1 Blockly

Event

Unit

Atomic Motion Base

Example

Realize the continuous rotation of the motor and the periodic swing of the servo

from m5stack import *
from m5ui import *
from uiflow import *
from base.Motion import Motion
import time

motion = Motion()
motion.set_motor_speed(1, 127)
motion.set_motor_speed(2, -127)
while True:
  motion.set_servo_angle(1, 90)
  motion.set_servo_angle(2, 90)
  motion.set_servo_angle(3, 90)
  motion.set_servo_angle(4, 90)
  wait(1)
  motion.set_servo_angle(1, 180)
  motion.set_servo_angle(2, 180)
  motion.set_servo_angle(3, 180)
  motion.set_servo_angle(4, 180)
  wait(1)
  wait_ms(2)

API

from base.Motion import Motion
motion = Motion()
  • Initialize Atomic Motion.
motion.set_motor_speed(ch, speed)
  • Control DC motor speed::
    • ch: 1-2
    • speed: -127 ~ +127, with 0 to stop.
motion.get_motor_speed(ch)
  • Get the DC motor speed configuration:
    • ch: 1-2
motion.set_servo_angle(ch, angle)
  • Control the servo rotation angle
    • ch: 1-4
    • angle: 0-180
motion.get_servo_angle(ch)
  • Get the servo rotation angle:
    • ch: 1-4
motion.set_servo_pulse(ch, pulse)
  • Control the servo pulse time (us):
    • ch: 1-4
    • pulse: 500-2500
motion.get_servo_pulse(ch)
  • Get the servo pulse time (us):
    • ch: 1-4
On This Page