pdf-icon

UIFlow Guide

UiFlow1 Blockly

Event

Unit

UiFlow1 Project

Unit PIR

Example

Detect the infrared state

from m5stack import *
from m5stack_ui import *
from uiflow import *
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
pir_0 = unit.get(unit.PIR, unit.PORTB)

while True:
  if (pir_0.state) == 1:
    print('PIR Status: Detected')
  else:
    print('PIR Status: Not detected')
  wait_ms(2)

API

print((str('status:') + str((pir_0.state))))
  • Obtain the sensing status of the device
On This Page