Ce site contient essentiellement des notes de travail. Le contenu est en constante évolution, et loin d'être achevé. (+ d'infos)
La plupart des documentations informatiques sont orientées Debian / Ubuntu.

Electronique/Hardware/Sensors/Infrarouge/Arduino - télécommande IR Nikon

De Ordinoscope.net
Sauter à la navigation Sauter à la recherche

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 */
void loop_39khz (int pin, int time) {
  static const int period = 25;
  static const int wait_time = 9;  

  for (time = time/period; time > 0; time--) {
    digitalWrite(pin, HIGH);
    delayMicroseconds(wait_time);
    digitalWrite(pin, LOW);
    delayMicroseconds(wait_time);
  }
}


void nikonSnap (int pin) {
  // 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/DelayMicroseconds
  delayMicroseconds (7830);
  delayMicroseconds (10000);
  delayMicroseconds (10000);
  loop_39khz (pin,390);
  delayMicroseconds (1580);
  loop_39khz (pin,410);
  delayMicroseconds(3580);
  loop_39khz (pin,400);
}

void setup () {
  pinMode(PIN_CAMERA, OUTPUT);
  digitalWrite (PIN_CAMERA, HIGH);
  delay (1000);
  digitalWrite (PIN_CAMERA, LOW);
}

void loop () {
  nikonSnap (PIN_CAMERA);
  delay (1000);
}

Références