I've created a library for controlling a camera's shutter. I've tested it with a Olympus SP510UZ but it should work for any camera that offers an electrical connection (as opposed to IR) for shutter triggering. It supports separate triggering of the focus and shutter functions. It also supports a camera's bulb triggering function (if it exists). I'd love to have this tested with other camera's
// File....... Camera.h
// Purpose.... Encapsulate the functionality associated with triggering a Camera
// Author..... Walter Anderson
// E-mail..... wandrson@walteranderson.us
// Started.... 5 May 2007
// Updated.... 12 May 2007
//
// This class is designed to encapsulate the functionality of triggering a
// two-stage shutter on a camera. The first stage triggers the camera auto-
// focus feature. The second stage of the trigger instructs the camera to
// take a photograph. Most camera's implement this as a half press for the
// focus function and a full button press for taking the picture. This module
// has been tested with an Olympus SP510UZ Digital Camera using a modified
// remote (RC-10UZ) to interface to the camera's proprietary accessory port.
//
class Camera
{
private:
long FocusPeriod; // Value used to determine period for triggering Camera's focus function.
int FocusTime; // Minimum time that this pin should be active for Focus Function on the Camera to be triggered
long ReTakeDelay; // Value to delay before allowing motion to trigger another shot.
int FocusPin; // Pin to trigger camera's focus function.
int ShutterPin; // Pin to trigger camera's shutter (take picture).
int ShutterTime; // Minimum time that this pin should be active for the shutter on the Camera to be triggered
int ShutterStatus; // toggle value
public:
Camera();
virtual ~Camera();
Camera(int fpin, int spin);
long getFocusPeriod();
long getReTakeDelay();
void setFocusPeriod(long lonValue);
void setReTakeDelay(long lonValue);
void ToggleShutter();
void TriggerFocus();
void TriggerShutter();
};
// File....... Camera.cpp
// Purpose.... Encapsulate the functionality associated with triggering a Camera
// Author..... Walter Anderson
// E-mail..... wandrson@walteranderson.us
// Started.... 5 May 2007
// Updated.... 12 May 2007
//
// This class is designed to encapsulate the functionality of triggering a
// two-stage shutter on a camera. The first stage triggers the camera auto-
// focus feature. The second stage of the trigger instructs the camera to
// take a photograph. Most camera's implement this as a half press for the
// focus function and a full button press for taking the picture. This module
// has been tested with an Olympus SP510UZ Digital Camera using a modified
// remote (RC-10UZ) to interface to the camera's proprietary accessory port.
//
#include "Camera.h"
#include <WConstants.h>
Camera::Camera(int fpin, int spin)
{
FocusPin = fpin;
ShutterPin = spin;
// Set pins as outputs
pinMode(FocusPin, OUTPUT);
pinMode(ShutterPin, OUTPUT);
// Set default pin status to low
digitalWrite(FocusPin, LOW);
digitalWrite(ShutterPin, LOW);
FocusTime = 100; // Default time to activate focus function is 100 ms.
ShutterTime = 100; // Default time to activare the camera's shutter is 100 ms.
FocusPeriod = 40000; // Default: Trigger Focus function every 40 seconds to keep camera powered up.
RetakeDelay = 30000; // Default: Wait a minimum of 30 seconds between photographs.
ShutterStatus = 0; // Shutter inactive
}
long Camera::getFocusPeriod()
{
return FocusPeriod;
}
long Camera::getRetakeDelay()
{
return RetakeDelay;
}
void Camera::setFocusPeriod(long lonValue)
{
FocusPeriod = lonValue;
}
void Camera::setRetakeDelay(long lonValue)
{
RetakeDelay = lonValue;
}
void Camera::ToggleShutter()
{
if (ShutterStatus == 0) {
digitalWrite(FocusPin, HIGH);
digitalWrite(ShutterPin, HIGH);
ShutterStatus = 1;
} else {
digitalWrite(FocusPin, LOW);
digitalWrite(ShutterPin, LOW);
ShutterStatus = 0;
}
}
void Camera::TriggerFocus()
{
digitalWrite(FocusPin, HIGH);
delay(FocusTime);
digitalWrite(FocusPin, LOW);
}
void Camera::TriggerShutter()
{
digitalWrite(FocusPin, HIGH);
delay(FocusTime);
digitalWrite(ShutterPin, HIGH);
delay(ShutterTime);
digitalWrite(ShutterPin, LOW);
digitalWrite(FocusPin, LOW);
}
keywords.txt
#######################################
Syntax Coloring Map For Test
#######################################
#######################################
Datatypes (KEYWORD1)
#######################################
Camera KEYWORD1
#######################################
Methods and Functions (KEYWORD2)
#######################################
getFocusPeriod KEYWORD2
getReTakeDelay KEYWORD2
setFocusPeriod KEYWORD2
setReTakeDelay KEYWORD2
ToggleShutter KEYWORD2
TriggerFocus KEYWORD2
TriggerShutter KEYWORD2
#######################################
Instances (KEYWORD2)
#######################################
#######################################
Constants (LITERAL1)
#######################################