Guest User

Dave's Photobooth

a guest
Oct 4th, 2014
319
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2.  
  3. import os
  4. import time
  5. from time import sleep
  6. import picamera
  7. import RPi.GPIO as GPIO
  8.  
  9.  
  10. ########################
  11. ### Variables Config ###
  12. ########################
  13.  
  14. button1_pin = 11
  15. led1_pin = 15 #red LED
  16. led2_pin = 13 # yellow LED
  17. led3_pin = 7 # green LED
  18.  
  19. total_pics = 4 # number of pics to be taken
  20. capture_delay = 2 # delay between pics
  21. prep_delay = 4 # number of seconds at step 1 as users prep to have photo taken
  22.  
  23. file_path = '/home/pi/photobooth/' #where do you want to save the photos
  24.  
  25. GPIO.setmode(GPIO.BOARD)
  26. GPIO.setup(button1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # falling edge detection on button 1
  27. GPIO.setup(led1_pin,GPIO.OUT) # LED 1 (red)
  28. GPIO.setup(led2_pin,GPIO.OUT) # LED 2 (yellow)
  29. GPIO.setup(led3_pin,GPIO.OUT) # LED 3 (green)
  30. GPIO.output(led1_pin,False);
  31. GPIO.output(led2_pin,False);
  32. GPIO.output(led3_pin,False);
  33.  
  34.  
  35. def start_photobooth():
  36. print "Get Ready"
  37. camera = picamera.PiCamera()
  38. camera.resolution = (640, 480) #use a smaller size to process faster
  39. camera.brightness = 55
  40. camera.vflip = False
  41. camera.hflip = True
  42. camera.start_preview()
  43. i=1
  44.  
  45.  
  46. print "Taking pics"
  47. now = time.strftime("%Y%m%d%H%M%S") #get the current date and time for the start of the filename
  48. try: #take the photos
  49. for i, filename in enumerate(camera.capture_continuous(file_path + now + '-' + '{counter:02d}.jpg')):
  50. GPIO.output(led1_pin,True)
  51. sleep(1)
  52. GPIO.output(led1_pin,False)
  53. GPIO.output(led2_pin,True)
  54. sleep(1)
  55. GPIO.output(led2_pin,False)
  56. GPIO.output(led3_pin,True) # turn on LED 3
  57. print(filename)
  58. sleep(1) #pause the LED on for just a bit
  59. GPIO.output(led3_pin,False) # turn off LED 3
  60. sleep(capture_delay) # pause in-between shots
  61. if i == total_pics-1:
  62. break
  63. finally:
  64. camera.stop_preview()
  65. camera.close()
  66.  
  67.  
  68. # wait for the big button to be pressed
  69. while True:
  70. GPIO.wait_for_edge(button1_pin, GPIO.FALLING)
  71. time.sleep(0.2) #debounce
  72. start_photobooth()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×