I am sure that the code could be cleaned up but it works for me at this point.
So far it will sit happily doing nothing. When the button is pushed it will show a preview for five seconds. Take the picture. Show the image for five seconds. Then back to the beginning.
A few things I plan to work on:
Need to make it auto run at boot
Create a message for people encouraging them to push the button
Create a count down visually on screen or with led
Auto upload to ftp server
The hope it to use this at our high school to gather buddy photos without a big production. Plug in and it works.
Code: Select all
import RPi.GPIO as GPIO import os from time import sleep os.system ('clear') GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP) def printFunction(channel): print('Button 1 pressed!') print('Note how the bouncetime affects the button press') GPIO.add_event_detect(23, GPIO.RISING, callback=printFunction, bouncetime=300) while True: GPIO.wait_for_edge(24, GPIO.FALLING) import time import datetime date = datetime.datetime.fromtimestamp(time.time()).strftime("_%Y-%m-%d_%H-%M-%S") os.system("raspistill -o /home/pi/click/images/image" + date + ".jpg") os.system('fbi --once -t 5 -a /home/pi/click/images/*.jpg') os.system('mv /home/pi/click/images/*.jpg /home/pi/click/images/old') os.system ('clear') sleep (5) GPIO.cleanup()