remote_fire_camera_via_gpio
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
remote_fire_camera_via_gpio [2017/02/04 16:38] – [Test Python Program With User Input] walkeradmin | remote_fire_camera_via_gpio [2017/10/22 16:43] – [See it in Action] walkeradmin | ||
---|---|---|---|
Line 35: | Line 35: | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{:canon_30d_remote_trigger_circuit.jpg?600|}} | + | {{:Canon 30D Remote Trigger 01.jpg?700|}} |
\\ | \\ | ||
\\ | \\ | ||
Line 47: | Line 47: | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{:canon_30d_remote_trigger_plug_description.jpg?400|}} | + | {{:Canon 30D Remote Trigger 02.jpg?400|}} |
\\ | \\ | ||
\\ | \\ | ||
Line 56: | Line 56: | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{: | + | {{: |
\\ | \\ | ||
\\ | \\ | ||
Line 91: | Line 91: | ||
\\ | \\ | ||
<color red> | <color red> | ||
- | <file> | + | \\ |
+ | <sxh [py][; options for SyntaxHighlighter]> | ||
#! / | #! / | ||
# Python Script to fire Canon camera using 2 GPIO pins. | # Python Script to fire Canon camera using 2 GPIO pins. | ||
# Version 1.0 | # Version 1.0 | ||
# Feb 2017 | # Feb 2017 | ||
+ | # Written in Python 2.7 | ||
# Import libraries | # Import libraries | ||
Line 129: | Line 131: | ||
# Cleanup GPIO | # Cleanup GPIO | ||
GPIO.cleanup() | GPIO.cleanup() | ||
- | </file> | + | </sxh> |
\\ | \\ | ||
---- | ---- | ||
==== Test Python Code With User Input ==== | ==== Test Python Code With User Input ==== | ||
+ | \\ | ||
+ | We have used a simple program to fire the camera, but more useful would be to have some options. The following code prompts the user for two inputs, the first input is the number of desired photos to be taken, the second is the delay between photos. | ||
+ | \\ | ||
+ | <sxh [py][; options for SyntaxHighlighter]> | ||
+ | #! / | ||
+ | # Python Script to fire Canon camera using 2 GPIO pins. | ||
+ | # The user will be asked for two values, one for the number of photos | ||
+ | # and one for the delay between photos. | ||
+ | # Version 2.0 | ||
+ | # Feb 2017 | ||
+ | # Written in Python 2.7 | ||
+ | |||
+ | import RPi.GPIO as GPIO | ||
+ | import time | ||
+ | |||
+ | # Ask for user input for number of photos, convert string to int | ||
+ | noOfPhotos=int(raw_input(" | ||
+ | print "you entered", | ||
+ | print "" | ||
+ | |||
+ | # Ask for user input for delay between photos, convert string to int | ||
+ | photoDelay=int(raw_input(" | ||
+ | print "you entered", | ||
+ | print "" | ||
+ | # Compensate for the 0.5s of delay in gpio loop (settling time) | ||
+ | photoDelay += -0.5 | ||
+ | |||
+ | # Define numbering system for the IO pins Raspberry Pi | ||
+ | GPIO.setmode(GPIO.BCM) | ||
+ | |||
+ | # Define GPIO ports for use with DSLR | ||
+ | gpioPins = (20,21) | ||
+ | |||
+ | # Setup channels for output and set initial values | ||
+ | for setPin in (gpioPins): | ||
+ | GPIO.setup(setPin, | ||
+ | GPIO.output(setPin, | ||
+ | |||
+ | # setup a loop for the number of photos the user entered (noOfPhotos) | ||
+ | while True: | ||
+ | print "Photo Number ", noOfPhotos | ||
+ | | ||
+ | for setPin in (gpioPins): | ||
+ | # Set first GPIO to High and wait 0.25s | ||
+ | GPIO.output(setPin, | ||
+ | time.sleep(0.25) | ||
+ | # Set second GPIO to High and wait 0.25s (just to settle) | ||
+ | GPIO.output(setPin, | ||
+ | time.sleep(0.25) | ||
+ | # Ensure GPIO Pins are set to low | ||
+ | for setPin in (gpioPins): | ||
+ | GPIO.output(setPin, | ||
+ | GPIO.output(setPin, | ||
+ | # decrement noOfPhotos | ||
+ | time.sleep(photoDelay) | ||
+ | noOfPhotos += -1 | ||
+ | # stop when noOfPhotos is equal to zero | ||
+ | if noOfPhotos == 0: | ||
+ | break | ||
+ | |||
+ | # Cleanup GPIO | ||
+ | GPIO.cleanup() | ||
+ | </ | ||
\\ | \\ | ||
\\ | \\ | ||
---- | ---- | ||
- | ==== The Python Code and Hardware | + | ==== See it in Action ==== |
\\ | \\ | ||
Well here is a short video of me running the code, seeing the camera take the shot and then the image coming up on the preview screen. Once you have got this far, you can now expand the software to do whatever you want. | Well here is a short video of me running the code, seeing the camera take the shot and then the image coming up on the preview screen. Once you have got this far, you can now expand the software to do whatever you want. | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{:dslr_test_video.mp4?640x360|}} | + | {{:canon_30d_raspberry_pi_trigger_test_video.mp4|950x574|autoplay, |
\\ | \\ | ||
\\ | \\ | ||
This code will form the start of my Raspberry Pi Intervalometer. This will be a great tool for static time lapse photography. Once this is done then I can move on to my camera slider project. However the actual slide rails for this will I think take me some time. | This code will form the start of my Raspberry Pi Intervalometer. This will be a great tool for static time lapse photography. Once this is done then I can move on to my camera slider project. However the actual slide rails for this will I think take me some time. | ||
\\ | \\ |
remote_fire_camera_via_gpio.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1