pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Unit Watering

案例程序

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

setScreenColor(0x222222)
Watering_0 = unit.get(unit.WATERING, unit.PORTB)

while True:
  print((str('Water: ') + str((Watering_0.get_adc_value()))))
  if (Watering_0.get_adc_value()) < 1000:
    Watering_0.set_pump_status(1)
  else:
    Watering_0.set_pump_status(0)
  wait(0.3)
  wait_ms(2)

功能说明

print(Watering_0.get_adc_value())
  • 获取Unit 检测的 ACD原始值
Watering_0.set_pump_status(0)
  • 通过变量 0 / 1 (ON/OFF)设置水泵的状态
Watering_0.set_pump_status(0)
  • 设置水泵状态ON/OFF
On This Page