pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Easy I/O

案例程序

读取数字引脚和模拟引脚的数值并显示在屏幕上

from m5stack import *
from m5stack_ui import *
from uiflow import *
from easyIO import *

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)

label0 = M5Label('label0', x=130, y=60, color=0x000, font=FONT_MONT_14, parent=None)
label1 = M5Label('label1', x=130, y=102, color=0x000, font=FONT_MONT_14, parent=None)

label0.set_text(str(analogRead(39)))
label1.set_text(str(digitalRead(0)))

功能说明

str(analogRead(39))
  • 设置ADC引脚,并读取模拟值
str(analogRead(39))
  • 设置ADC引脚,并读取模拟值
str(digitalRead(0))
  • 设置数字引脚,并读取电平值
str(map_value(0, 0, 1023, 0, 4))
  • map映射函数
    • "0":需要映射的变量
    • "0":变量的最小值
    • "1023":变量的最大值
    • "0":映射输出的最小值
    • "4":映射输出的最大值
analogWrite(26, 0)
  • 设置模拟引脚的输出占空比
digitalWrite(26, 0)
  • 设置数字引脚的输出电平值
toggleIO(26)
  • 切换引脚电平值
On This Page