pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Vibrator

案例程序

from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
vibrator_0 = unit.get(unit.VIBRATOR, unit.PORTA)

def buttonA_wasPressed():
  # global params
  vibrator_0.off()
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  vibrator_0.on(10)
  pass
btnB.wasPressed(buttonB_wasPressed)

功能说明

vibrator_0.off()
  • 关闭电机
vibrator_0.on(10)
  • 设置振动占空比
On This Page