Arduino – motion triggered camera

Nikon D80 Motion sensor trigger

So having worked out that I can make a remote for my Nikon D80 to do some timelapse photography. I started thinking of things I can do to trigger the remote, below video shows it working but you’ll need sound to hear the shutter going.

First of all check out my tutorial for making the remote as this builds on that tutorial – also saves me having to recap and explain that. Arduino Nikon intervalometer infrared remote for timelapse photography.

Ok so now you know how I’m going to trigger the camera to take pictures. So now we need the sensor, for this I’m going to use a PIR (Pyroelectric InfraRed sensor) IC that works like a switch turning on when motion is detected, the one I’m using is basically a couple of IR emitters and sensors under a Fresnel lens – word of warning make sure you get the power supply right as they tend to smoke otherwise!. It works by measuring any difference to the background temperature and infrared radiation. I’ve also added an LED to signal when the PIR is on or off.

The biggest challenge for this was making sure the camera didn’t keep triggering for the length of time the PIR was active – sometimes it would be active for 5 or seconds after initial movement, so I wanted to capture say 2 photos for each time it was triggered.

For lazyness I’ve left my camera in auto setting so that it *should* autofocus along with everything else – e.g. exposure times and apertures.

Arduino Motion Tracker Parts

220 Ohm resistor (Red, Red, Brown, Gold)
10K Ohm resistor (Brown, Black, Orange, Gold)
PIR sensor
Infrared emitting diode
Arduino Deumilanove w/ ATMEGA328
Breadboard / Prototyping board
Jumper/ Connector wires
Optional 9V power supply (here) or use the USB power for the Arduino
You will also need a soldering iron and solder if you use the same PIR as myself.

The Arduino Motion Detector Circuit

You may not be able to see but I’ve used the power supply from the Arduino to power the breadboard. The PIR gets its supply from this and there’s a 10k Ohm resistor between its output pin and pin 4 on the Arduino. The LED has a 220 Ohm resistor between that and the digital pin 9. The IR LED I’ve left in pin 13 and grounded – for a better system I would solder on a couple of wires to allow more flexibility with transmitting the signal. Also for the PIR, the one I have I had to solder a few jumper wires into the back of it just so you know.


Arduino Motion Sketch / Code

Based off of my remote tutorial I’ve just added in a few extra things really. An output for the LED, an input for the PIR and a chunk of code to limit the taking of photos.
[ad#Google Ad in content]


LUCKYLARRY.CO.UK - IR Remote control for Nikon using Arduino with motion trigger

Uses a PIR sensor to trigger the camera remote/ IR led if a change in background
temperature is detected.


int currentState = 0;                                   // set a variable to store a count.
int pinPIR = 4;                                         // digital pin 4 for PIR
int pinLED = 9;                                         // digital pin 9 for LED
int pinIRLED = 13;                                      // assign the Infrared emitter/ diode to pin 13

void setup() {
  pinMode(pinIRLED, OUTPUT);                            // set the pin as an output
  pinMode(pinLED, OUTPUT);                              // set the LED pin as ouput
  pinMode(pinPIR, INPUT);                               // set the PIR pin as an input

// sets the pulse of the IR signal.
void pulseON(int pulseTime) {
  unsigned long endPulse = micros() + pulseTime;        // create the microseconds to pulse for
  while( micros() < endPulse) {
    digitalWrite(pinIRLED, HIGH);                       // turn IR on
    delayMicroseconds(13);                              // half the clock cycle for 38Khz (26.32×10-6s) - e.g. the 'on' part of our wave
    digitalWrite(pinIRLED, LOW);                        // turn IR off
    delayMicroseconds(13);                              // delay for the other half of the cycle to generate wave/ oscillation


void pulseOFF(unsigned long startDelay) {
  unsigned long endDelay = micros() + startDelay;       // create the microseconds to delay for
  while(micros() < endDelay);

void takePicture() {
  for (int i=0; i < 2; i++) {
    pulseON(2000);                                      // pulse for 2000 uS (Microseconds)
    pulseOFF(27850);                                    // turn pulse off for 27850 us
    pulseON(390);                                       // and so on
  }                                                     // loop the signal twice.

void loop() {

  if ((digitalRead(pinPIR) == LOW) && (currentState <= 2)) { // count to limit the taking of photos
    takePicture();                                      // take the picture
    digitalWrite(pinLED, HIGH);                         // turn LED on
  } else {
    digitalWrite(pinLED, LOW);
    currentState = 0;                                   //reset the count when the PIR is off.

  delay(2000);                                          // delay for 2 seconds - 2 seconds between taking photos if the PIR is active for more than 2 seconds.

[ad#Google Ad in content]

I think adding in another PIR would help me make some kind of turret system. Also you could use the ultrasonic range finder jobby, the SRF-05, to detect the distance and if less than say 3 metres take the photo etc.. I'm also going to try and setup a trip-wire system to trigger the camera :)


  • Very cool stuff. I am going to try to follow the instructable to setup one myself for my photography studio. I want a motion sensor to trigger my D90 to take a shot just as whatever I drop in liquid splashes up.

    • You’ll need a faster trigger than the motion sensor – I would do a laser beam into a LDR and as the object passes through set the camera to fire just after that so you’ll have a better chance of getting the splash.

  • Hey i have the bigger version of this ( and am wondering if you know how to set up this circuit with that board (if possible).

  • Hi,
    I’m kind of new to this but i have 2 questions: could i use this to trigger a Nikon d60 (or the ir receiver is different) and what ir didode are you using or isn’t imortant?

    • hi, its not important really what type of IR diode you use, they should all work but the difference will be how strong a signal they can send – some devices also need a specific wavelength but in this case any IR will work.

      Should wrk with any Nikon DLSR camera as long as you have an infrared port on it – looks like a small shiny black circle/oval on the front of the camera.

  • Fine presentation and website. I’m hooking my Nikon body to my Meade 125X telescope for timelapse tracking of Jupiter’s moons. Maybe Galilieo was wrong? Still can’t remember how to spell him.

    My other problem is to have the ono/datalogger print the time when an “event” occurs from the PIR. Problem is: the PIR fires spontaneously, which has something to do with the electricity in my work shack. When I turn off the halogen and fluorescent lights, it calms down. Here’s what you said above, “Also for the PIR, the one I have I had to solder a few jumper wires into the back of it just so you know.” Did you do this to stop the PIR talking too much? If so, can you tell me where the jumpers go?

  • hi, im wondering if you could put the circuit diagram in here? its hard to follow the circuit just by looking at the picture. thank you. very interesting stuff.

  • […] Arduino based motion triggered camera using a PIR sensor […]

  • Hi Larry!

    Regarding your motion triggered camera, will it be possible to use a video camera to record the motion and save it on any device capable of storing data. e.g. Laptop,memory stick, external hard drive. etc.

  • Hi Larry,

    Thanks for sharing this.
    It is little difficult to see on the picture, but isn’t the 10k resistor short circuited?


  • Thanks for sharing. I’ve been learning Arduino myself recently and built my first camera control project a few weeks back so I already have those basics to build on. This looks an interesting add on to try at some point.

  • i want to controll camera using pir sensor for human detection and security survielence??

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>