English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Hat Balac

Example

Control the balac to move forward, turn left or right, and move backward.

from m5stack import *
from m5ui import *
from uiflow import *
import time
import hat

setScreenColor(0x111111)

balac = hat.get(hat.BALAC)

balac.set_motor_speed(1, 50)
balac.set_motor_speed(2, 50)
wait(1)
balac.set_motor_speed(1, 50)
balac.set_motor_speed(2, 0)
wait(1)
balac.set_motor_speed(1, 0)
balac.set_motor_speed(2, 50)
wait(1)
balac.set_motor_speed(1, -50)
balac.set_motor_speed(2, -50)
wait(1)
balac.stop_motor(1)
wait(1)

API

balac.set_motor_speed(1, 50)
  • Set the speed of DC Motor A, with the current speed set to 50 (maximum speed is 255).
balac.stop_motor(1)
  • Stop the operation of DC Motor A.
Page Tools
PDF
On This Page