I'm using a simple laser beam alarm circuit similar to http://2.bp.blogspot.com/-DlpGa_yyJ0Y/U ... iagram.png
I took a input from this circuit to the Pi using a 4k7 resistor instead of the buzzer and capture images when the beam get obstructed. I used the pigpio library callback function to capture images as
import pigpio
import os
pi=pigpio.pi()
pi.set_mode(4,pigpio.INPUT)
pi.set_pull_up_down(4,pigpio.PUD_DOWN)
i=0
def capture(gpio,level,ticks):
global i
i=i+1
os.system(("raspistill -o img%s.png -md 6 -t 500")%i)
callf=pi.callback(4, pigpio.RISING_EDGE, capture)
while True:
pass
but the issue was sometimes it capture multiple images for single obstruct. I found out that debounce is a solution for this kind of situations. How to use debouncing with the pigpio library.