pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

PbHUB

Example

Control Motor Rotation

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

setScreenColor(0x222222)
pbhub_0 = unit.get(unit.PBHUB, unit.PORTA)

while True:
  pbhub_0.setServoAngle(0, 0, 11)
  wait(1)
  pbhub_0.setServoAngle(0, 0, 180)
  wait(1)
  wait_ms(2)

API

pbhub_0.init_i2c_address(0x61)
  • Initialize I2C Address
print(pbhub_0.analogRead(0))
  • Read Analog Value
print(pbhub_0.digitalRead(0, 0))
  • Read Digital Value
pbhub_0.digitalWrite(0, 0, 0)
  • Write Digital Value
print(pbhub_0.pwmRead(0, 0))
  • Read Pulse from Pin
pbhub_0.pwmWrite(0, 0, 0)
  • Write Pulse to Pin
print(pbhub_0.read_status(0xFE))
  • Read Unit Status/Version Number
pbhub_0.setBrightness(0, 50)
  • Set RGB LED Brightness
pbhub_0.setColorPos(0, 0, 0xff0000)
  • Set RGB LED Color
pbhub_0.setColorPos(0, 0, 0xff0000)
  • Set Range of RGB LED Colors
pbhub_0.setColor(0, 0, 0, 0xff0000)
  • 设置指定引脚对应指定范围RGB灯珠的颜色
pbhub_0.setColor(0, 0, 0, 0xff0000)
  • Set Range of RGB LED Colors (Multiple Formats)
pbhub_0.setRgbNum(0, 1)
  • Set LED Light on Specified Pin
pbhub_0.init_i2c_address(0x61)
  • Set Firmware Version/I2C Address
pbhub_0.setServoAngle(0, 0, 90)
  • Set Servo Motor Angle
pbhub_0.setServoPulse(0, 0, 1000)
  • Write Digital Value (Duplicate)
On This Page