pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Ext IO

Example

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)

API

print(ext_io_0.digitReadPort())
  • Read all pin status
print(ext_io_0.digitRead(0))
  • Reads the specified pin state
ext_io_0.digitWrite(0,0)
  • Pin state is controlled separately
ext_io_0.digitWritePort(0x68)
  • Control pin state, each pin corresponds to 1 bit
ext_io_0.setPinMode(0, ext_io_0.INPUT)
  • Set the input or output separately
ext_io_0.setPortMode(ext_io_0.ALL_INPUT)
  • All pins are set to input or output mode
On This Page