Hardware Reference
In-Depth Information
To start your sketch,
import the MultiCam-
eraIrControl library. Initialize the library
to send signals on pin 3, to which the
LED is connected. Then, set up a few
variables to keep track of the state of
the pushbutton.
Try It
/*
IR Camera control
Context: Arduino
This sketch controls a digital camera via an infrared LED.
*/
// include the library for camera control:
#include <multiCameraIrControl.h>
const int pushButtonPin = 4;
// set up pin 3 to control the IR LED.
// change this depending on the brand of your camera:
Nikon camera(3);
// Variables will change:
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
8
The setup method initializes the
pushbutton as an input.
void setup(){
// initialize the pushButton as input:
pinMode(pushButtonPin, INPUT);
}
8
The main loop listens for the
pushbutton's state to change. Since
you don't want the camera firing all the
time, trigger the camera only when the
pushbutton changes from OFF to ON.
To do that, compare the button's state
to its previous state by storing the
current state as the previous state at
the end of each loop.
void loop(){
// read the pushbutton input pin:
buttonState = digitalRead(pushButtonPin);
// compare the buttonState to its previous state
// if it's changed, and it's high now, then the person
// just punched the button:
if (buttonState != lastButtonState && buttonState == HIGH) {
// send the signal to open the shutter:
camera.shutterNow();
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}
That's the whole program. Now point
the LED at your camera and start
taking some pictures remotely. You
may have to set your camera to remote
control mode. Check the camera
manual for how to do this, as it's
different from camera to camera.
 
Search WWH ::




Custom Search