import time
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
while True:
if GPIO.input(23)==1:
os.system('raspistill -o image.jpg')
os.system(‘gpicview image.jpg &’)
sleep(20)
os.system(‘killall gpicview’)
else:
print "Ready to take picture"
GPIO.cleanup()
亲爱的 friend 们,我正在尝试用按钮控制树莓派相机。就像当我按下按钮时它应该拍照。我配置了 GPIO 引脚和按钮,当我按下按钮时,没有任何反应,但是 picamera 自己拍照。我怎样才能让它与按钮一起工作?有 python 方面的专家可以指导我吗?谢谢!
最佳答案
硬件不会给我们一个干净的 1 或 0,它会来回跳动。检查此代码以“消除弹跳”按钮:
https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/robot/buttons_and_switches/
关于python - 使用GPIO通过按钮控制树莓派picamera,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22254610/