import RPi.GPIO as GPIO
import time
def init():
GPIO.setwarnings(False)
Gpio.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.in)
GPIO.setup(29,GPIO.out)
pass
def beep():
while GPIO.input(12):
GPIO.output(29,GPIO.LOW)
time.sleep(0.5)
GPIO.output(29,GPIO.HIGH)
time.sleep(0.5)
def detct():
for i in range(1,101):
if GPIO.input(12)) == True:
print("有人靠近!")
beep()
else:
GPIo.output(29,GPIO.HIGH)
print("没有人!")
time.sleep(2)
time.sleep(5)
init()
detct()
GPIO.cleanup()
如果 while GPIO.input(12):
就执行这行代码。sudo fswebcam -d /dev/ video0 -r --320x240 --bottom-banner --tittle "RaspberryPi@Yeelink" --save /home/pi/yeelink/yeelink.jpg
谁帮我看下,这个应该怎么弄
|