Code

// Adaptation of the code from http://www.vonroth.com/Arduino/NikonIrControl/#include"WProgram.h"#define PIN_CAMERA 13// This 39kHz loop from http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/* Modulate pin at 39 kHz for give number of microseconds */voidloop_39khz(intpin,inttime){staticconstintperiod=25;staticconstintwait_time=9;for(time=time/period;time>0;time--){digitalWrite(pin,HIGH);delayMicroseconds(wait_time);digitalWrite(pin,LOW);delayMicroseconds(wait_time);}}voidnikonSnap(intpin){// These Timing are from: http://www.bigmike.it/ircontrol/loop_39khz(pin,2000);//This Delay is broken into 3 lines because the delayMicroseconds() is only accurate to 16383. http://arduino.cc/en/Reference/DelayMicrosecondsdelayMicroseconds(7830);delayMicroseconds(10000);delayMicroseconds(10000);loop_39khz(pin,390);delayMicroseconds(1580);loop_39khz(pin,410);delayMicroseconds(3580);loop_39khz(pin,400);}voidsetup(){pinMode(PIN_CAMERA,OUTPUT);digitalWrite(PIN_CAMERA,HIGH);delay(1000);digitalWrite(PIN_CAMERA,LOW);}voidloop(){nikonSnap(PIN_CAMERA);delay(1000);}