treypop
Posts: 2
Joined: Tue Jun 26, 2018 9:56 pm

can't figure out how to get button to work with my pi camera

Sat Aug 11, 2018 3:25 am

I'm new to the raspberry pi and cant figure out how to get this button working using the GPIO pins.

the code I script I made for taking the pictures

import os
import picamera


try:
os.stat('/home/pi/photos')
except OSError:
print "Creating the photos directory under /home/pi..."
os.makedirs('/home/pi/photos')
files = os.listdir('/home/pi/photos/')
howmany = files.__len__()
camera = picamera.PiCamera()
camera.resolution = (2592, 1944)
if howmany > 0:
camera.capture('/home/pi/photos/Picture' + str(howmany) + '.jpg')
else:
camera.capture('/home/pi/photos/Picture.jpg')

Can someone amend my code for the GPIO or tell me how to go about it.

B.Goode
Posts: 6544
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: can't figure out how to get button to work with my pi camera

Sat Aug 11, 2018 6:26 am

There is an example here using the gpiozero python library module installed by default in recent versions of the Raspbian Operating System.

https://gpiozero.readthedocs.io/en/stab ... led-camera

(If the link does not take you to the correct part of the document, look for the section headed 2.7. Button controlled camera.)

Return to “Camera board”