Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import subprocess
  2. import RPi.GPIO as GPIO
  3. import time
  4. import datetime
  5. import picamera
  6.  
  7. GPIO.setmode(GPIO.BCM)
  8. GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  9.  
  10. def get_file_name_pic():
  11. return datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S.jpg")
  12.  
  13. with picamera.PiCamera() as camera:
  14. while True:
  15. input_state = GPIO.input(21)
  16. if input_state == False:
  17. print('Taking Picture...')
  18. camera.capture('/home/pi/'+get_file_name_pic())
  19. time.sleep(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement