User Tools

Site Tools


remote_fire_camera_via_gpio

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
remote_fire_camera_via_gpio [2017/02/04 16:38] – [Test Python Program With User Input] walkeradminremote_fire_camera_via_gpio [2023/03/09 22:35] (current) – external edit 127.0.0.1
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:
 \\  \\ 
 \\  \\ 
-{{:3poleplugcanon.jpg?350|}}+{{:3poleplugcanon.jpg?400|}}
 \\  \\ 
 \\  \\ 
Line 91: Line 91:
 \\  \\ 
 <color red>Remember:</color> if you don't set the pins to low after shooting, it's the same as keeping your finger on the shutter button, the camera will just stay in shooting mode (but the shutter will close) and you won't see your preview image or be able to take any more shots. <color red>Remember:</color> if you don't set the pins to low after shooting, it's the same as keeping your finger on the shutter button, the camera will just stay in shooting mode (but the shutter will close) and you won't see your preview image or be able to take any more shots.
-<file>+\\  
 +<sxh [py][; options for SyntaxHighlighter]>
 #! /usr/bin/python #! /usr/bin/python
 # 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]>
 +#! /usr/bin/python
 +# 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("How Many Photos? "))
 +print "you entered", noOfPhotos
 +print ""
 +
 +# Ask for user input for delay between photos, convert string to int 
 +photoDelay=int(raw_input("How Many Seconds between Photos? "))
 +print "you entered", photoDelay
 +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.OUT)
 +  GPIO.output(setPin,GPIO.LOW)
 +
 +# 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,GPIO.HIGH)
 +        time.sleep(0.25)
 +      # Set second GPIO to High and wait 0.25s (just to settle)
 +        GPIO.output(setPin,GPIO.HIGH)
 +        time.sleep(0.25)
 +      # Ensure GPIO Pins are set to low
 +      for setPin in (gpioPins):
 +        GPIO.output(setPin,GPIO.LOW)
 +        GPIO.output(setPin,GPIO.LOW)
 +      # decrement noOfPhotos
 +      time.sleep(photoDelay)
 +      noOfPhotos += -1
 +      # stop when noOfPhotos is equal to zero
 +      if noOfPhotos == 0:
 +          break
 + 
 +# Cleanup GPIO
 +GPIO.cleanup()
 +</sxh>
 \\  \\ 
 \\  \\ 
  
 ---- ----
-==== The Python Code and Hardware in Action ====+==== 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,loop}}
 \\  \\ 
 \\  \\ 
 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