pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Ext IO

案例程序

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

setScreenColor(0x222222)
ext_io_0 = unit.get(unit.EXT_IO, unit.PORTA)

ext_io_0.setPortMode(ext_io_0.ALL_OUTPUT)
while True:
  ext_io_0.digitWrite(1,0)
  wait(0.2)
  ext_io_0.digitWrite(2,0)
  wait(0.2)
  ext_io_0.digitWrite(3,0)
  wait(0.2)
  ext_io_0.digitWrite(4,0)
  wait(0.2)
  ext_io_0.digitWrite(1,1)
  wait(0.2)
  ext_io_0.digitWrite(2,1)
  wait(0.2)
  ext_io_0.digitWrite(3,1)
  wait(0.2)
  ext_io_0.digitWrite(4,1)
  wait(0.2)
  wait_ms(2)

功能说明

print(ext_io_0.digitReadPort())
  • 读取全部引脚状态
print(ext_io_0.digitRead(0))
  • 读取指定引脚状态
ext_io_0.digitWrite(0,0)
  • 单独控制引脚状态
ext_io_0.digitWritePort(0x68)
  • 控制引脚状态,每个引脚对应1位
ext_io_0.setPinMode(0, ext_io_0.INPUT)
  • 单独设置输入或输出
ext_io_0.setPortMode(ext_io_0.ALL_INPUT)
  • 全部引脚设置为输入或输出模式
On This Page