English
English
简体中文
日本語

UiFlow Tutorial

UiFlow1 Development Guide

Project Management

Use LTE network

UiFlow1 Blockly

Event

Unit

Hat Vibrator

Example

Increases vibration intensity every second.

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

setScreenColor(0x111111)

hat_vibrator_0 = hat.get(hat.VIBRATOR)

while True:
  hat_vibrator_0.set_duty(10)
  wait(1)
  hat_vibrator_0.set_duty(30)
  wait(1)
  hat_vibrator_0.set_duty(50)
  wait(1)
  hat_vibrator_0.set_duty(70)
  wait(1)
  hat_vibrator_0.set_duty(100)
  wait(1)
  hat_vibrator_0.turn_off()
  wait(1)
  wait_ms(2)

API

hat_vibrator_0.set_duty(50)
  • Sets the motor drive signal duty cycle (e.g., 50%) to adjust the proportion of powered time in each cycle and change the vibration intensity.
hat_vibrator_0.set_freq(10)
  • Sets the motor drive signal frequency (e.g., 10 Hz). Together with the duty cycle, this controls the drive pulses. This parameter does not specify the motor's actual mechanical vibration frequency.
hat_vibrator_0.turn_off()
  • Turns off the vibrator, stopping its operation.
Page Tools
PDF
On This Page