Skip to content

Instantly share code, notes, and snippets.

@honnet
Created April 17, 2019 15:57
Show Gist options
  • Save honnet/86c26a626b65f17a3867213d681a1286 to your computer and use it in GitHub Desktop.
Save honnet/86c26a626b65f17a3867213d681a1286 to your computer and use it in GitHub Desktop.
Code to trigger photos with arduino (ESP8266) and infrared to control a Nikon D5300.
// inspiration: https://www.christidis.info/index.php/personal-projects/arduino-nikon-infrared-command-code
const int LEDpin = D3;
const int delay_us = 13; // 38 KHz
int i;
void setup() {
pinMode(LEDpin, OUTPUT);
}
void loop() {
takePhoto();
delay(1000);
}
void takePhoto(void) {
for (i = 0; i < 76; i++) {
digitalWrite(LEDpin, HIGH);
delayMicroseconds(delay_us);
digitalWrite(LEDpin, LOW);
delayMicroseconds(delay_us);
}
delayMicroseconds(27880);
for (i = 0; i < 16; i++) {
digitalWrite(LEDpin, HIGH);
delayMicroseconds(delay_us);
digitalWrite(LEDpin, LOW);
delayMicroseconds(delay_us);
}
delayMicroseconds(1486);
for (i = 0; i < 16; i++) {
digitalWrite(LEDpin, HIGH);
delayMicroseconds(delay_us);
digitalWrite(LEDpin, LOW);
delayMicroseconds(delay_us);
}
delayMicroseconds(3484);
for (i = 0; i < 16; i++) {
digitalWrite(LEDpin, HIGH);
delayMicroseconds(delay_us);
digitalWrite(LEDpin, LOW);
delayMicroseconds(delay_us);
}
}
@honnet
Copy link
Author

honnet commented Apr 17, 2019

Schematics example:
https://cdn.instructables.com/FGC/3H3P/IJAACJL3/FGC3H3PIJAACJL3.LARGE.jpg

Logic analyser visualization (top = pulsed light // bottom = envelop):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment