Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import RPi.GPIO as GPIO, time, os, subprocess
- # GPIO setup
- GPIO.setmode(GPIO.BCM)
- SWITCH = 24
- GPIO.setup(SWITCH, GPIO.IN)
- PRINT_LED = 22
- POSE_LED = 18
- BUTTON_LED = 23
- GPIO.setup(POSE_LED, GPIO.OUT)
- GPIO.setup(BUTTON_LED, GPIO.OUT)
- GPIO.output(BUTTON_LED, True)
- while True:
- if (GPIO.input(SWITCH)):
- time.sleep(0.001)
- snap = 0
- while snap < 4:
- print("pose!")
- GPIO.output(BUTTON_LED, False)
- GPIO.output(POSE_LED, True)
- time.sleep(1.5)
- for i in range(5):
- GPIO.output(POSE_LED, False)
- time.sleep(0.4)
- GPIO.output(POSE_LED, True)
- time.sleep(0.4)
- for i in range(5):
- GPIO.output(POSE_LED, False)
- time.sleep(0.1)
- GPIO.output(POSE_LED, True)
- time.sleep(0.1)
- GPIO.output(POSE_LED, False)
- print("SNAP")
- gpout = subprocess.check_output("gphoto2 --capture-image-and-download --filename /home/pi/photobooth_images/photobooth%H%M%S.jpg", stderr=subprocess.STDOUT, shell=True)
- print(gpout)
- if "ERROR" not in gpout:
- snap += 1
- GPIO.output(POSE_LED, False)
- time.sleep(0.5)
- GPIO.output(PRINT_LED, False)
- GPIO.output(BUTTON_LED, True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement