The gravity IR transmitter module will fire off an IR signal that the camera can recognize, and already has resistors integrated right on the board so I can just plug and play!
I have used a gravity button to fire the shutter when pressed. Again, all the components and resistors to make it work properly are integrated right on to the module’s board, so I can just plug and play.
IR devices such as remotes use invisible infra-red light and usually communicate by firing a specific set of pulses of light from an IR transmitter that the IR receiver on a device can recognise and decode.
PWM ON | OFF |
2.0 ms | 27 ms |
0.4 ms | 1.5 ms |
0.5 ms | 3.5 ms |
0.5 ms | 62.2 ms |
2.0 ms | 27 ms |
0.5 ms | 1.5 ms |
0.5 ms | 3.5 ms |
0.5 ms |
int IRledPin = 13;
int buttonPin = 2;
void setup() {
pinMode(IRledPin, OUTPUT);
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop() {
int val = digitalRead(buttonPin);
if (val == HIGH) {
SendNikonCode();
Serial.println("Sending IR signal");
}
}
void pulseIR(long microsecs) {
cli();
while (microsecs > 0) {
digitalWrite(IRledPin, HIGH);
delayMicroseconds(10);
digitalWrite(IRledPin, LOW);
delayMicroseconds(10);
microsecs -= 26;
}
sei();
}
void SendNikonCode() {
pulseIR(2080);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
delay(65);
pulseIR(2000);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
}
It might not look like It, but this code is relatively simple:
/*
Nikon D40 Intervalometer
By Matt
15.10.2016
*/
# define interval 60 //set interval time in seconds
int intervalTime = (interval * 1000); //convert interval from seconds to milliseconds
int IRledPin = 13; // LED connected to digital pin 13
int buttonPin = 2; // push button connected to pin 2
volatile int buttonState = 0; // variable for reading pushbutton status
void setup() {
pinMode(IRledPin, OUTPUT); // initialize the IR digital pin as an output:
pinMode(buttonPin, INPUT); // initialize the button as an input
attachInterrupt(0, pinISR, CHANGE); // attach an interrupt to the ISR vector
Serial.begin(9600); // start serial communication for debugging
}
void loop() {
SendNikonCode(); // fire shutter
Serial.println("Sending IR signal");// print message on serial monitor
delay(intervalTime); // wait this amount of time before firing again
}
void pinISR() {
int val = digitalRead(buttonPin); // read button pin state
if (val == HIGH) { // if button is pressed
Serial.println("Sending IR signal"); // print to serial monitor
SendNikonCode(); // fire shutter
}
}
// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0) {
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}
void SendNikonCode() {
// This is the code for my particular Nikon, for others use the tutorial
// to 'grab' the proper code from the remote
pulseIR(2080);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
delay(65); // wait 65 milliseconds before sending it again
pulseIR(2000);
delay(27);
pulseIR(440);
delayMicroseconds(1500);
pulseIR(460);
delayMicroseconds(3440);
pulseIR(480);
}
I have also uploaded this code to github for your convenience.
At the end of the day I took the images and processed them in VirtualDub to turn them in to a movie. You can find out more about how to do this here: http://timelapseblog.com/2009/08/04/using-virtualdub-for-time-lapse/
Here are some timelapses I took using this setup, I hope you like them:
Conclusion:
This is a relatively easy Arduino project for beginners and can be done over a weekend. It provides lots of scope for expansion allowing you to create other photography triggers. You could take this code and replace the button with a PIR sensor to it so that the shutter fires when someone walks past the camera. You could even take the circuit and add a light sensor in to it and tweak the code so that during a thunderstorm the camera will fire when lightning strikes – that would make for some great photos!
All the components used in this Arduino project and more can be found on DFRobot.com
If you try this out please share your results on the DFRobot forum!