'''
实验名称：人体红外感应传感器
实验平台：核桃派1B
'''

#导入相关模块
import time,board
from digitalio import DigitalInOut, Direction, Pull

# 初始化人体红外感应传感器对象，引脚为PC8.
human = DigitalInOut(board.PC8) #定义引脚编号
human.direction = Direction.INPUT #IO为输入

#构建LED对象和初始化
led = DigitalInOut(board.LED) #定义引脚编号
led.direction = Direction.OUTPUT  #IO为输出

while True:

    if human.value == 1: #有人
        
        led.value = 1 #点亮LED

    else: #没人
        
        led.value = 0 #关闭LED

    time.sleep(0.5) #检测周期0.5秒
