Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import RPi.GPIO as GPIO, time, os, subprocess
  4.  
  5. # GPIO setup
  6. GPIO.setmode(GPIO.BCM)
  7. SWITCH = 24
  8. GPIO.setup(SWITCH, GPIO.IN)
  9.  
  10. PRINT_LED = 22
  11. POSE_LED = 18
  12. BUTTON_LED = 23
  13. GPIO.setup(POSE_LED, GPIO.OUT)
  14. GPIO.setup(BUTTON_LED, GPIO.OUT)
  15. GPIO.output(BUTTON_LED, True)
  16.  
  17.  
  18. while True:
  19. if (GPIO.input(SWITCH)):
  20. time.sleep(0.001)
  21. snap = 0
  22. while snap < 4:
  23. print("pose!")
  24. GPIO.output(BUTTON_LED, False)
  25. GPIO.output(POSE_LED, True)
  26. time.sleep(1.5)
  27. for i in range(5):
  28. GPIO.output(POSE_LED, False)
  29. time.sleep(0.4)
  30. GPIO.output(POSE_LED, True)
  31. time.sleep(0.4)
  32. for i in range(5):
  33. GPIO.output(POSE_LED, False)
  34. time.sleep(0.1)
  35. GPIO.output(POSE_LED, True)
  36. time.sleep(0.1)
  37. GPIO.output(POSE_LED, False)
  38. print("SNAP")
  39. gpout = subprocess.check_output("gphoto2 --capture-image-and-download --filename /home/pi/photobooth_images/photobooth%H%M%S.jpg", stderr=subprocess.STDOUT, shell=True)
  40. print(gpout)
  41. if "ERROR" not in gpout:
  42. snap += 1
  43. GPIO.output(POSE_LED, False)
  44. time.sleep(0.5)
  45.  
  46. GPIO.output(PRINT_LED, False)
  47. GPIO.output(BUTTON_LED, True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement