本站改版新增arduino频道
人体感应传感器
import time
from machine import SoftI2C,Pin #从machine模块导入I2C、Pin子模块
Human=Pin(4,Pin.IN,Pin.PULL_UP) #构建人体红外对象
#初始信息显示
print("Human body test:") # 写入第2行内容
def fun(Human): #Get People闪烁5次效果!
for i in range(5):
print("Human body test:", 0, 15) # 写入第2行内容
print("Get People!!!", 0, 40) # 写入第3行内容
time.sleep_ms(500)
print("Human body test:", 0, 15) # 写入第2行内容
print(" ", 0, 40) # 写入第3行内容
time.sleep_ms(500)
Human.irq(fun,Pin.IRQ_RISING) #定义中断,上升沿触发
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0092802047729492 seconds