接线方法github
GPIO4
号口。from gpiozero import MotionSensor pir = MotionSensor(4) while True : if pir.value: print("有人!") else: print("没人!")
value
传感器在激活状态下,返回1。在沉默状态下,返回0。api
wait_for_motion(timeout=None)
阻塞进程,检测到人体运动才返回,继续执行。微信
wait_for_no_motion(timeout=None)
阻塞进程,检测到人体运动中止才返回,继续执行。函数
when_motion
不阻塞进程,检测到人体运动则自动执行函数。学习
when_no_motion
不阻塞进程,检测到人体运动中止则自动执行函数。人工智能
好了,本次介绍就到这里,本文收录在个人《手把手教你玩树莓派》系列教程,立足于普及树莓派搭配人工智能、物联网和机器人的玩法,想要跟我一块儿学习的童鞋能够加我微信/微博ID:asukafighting,也能够直接看教程:https://github.com/asukafight...spa