forked from gicmo/rgb-led
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nikon.cc
37 lines (33 loc) · 827 Bytes
/
nikon.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "nikon.h"
NikonRemote::NikonRemote( unsigned int ir_pin ) {
this->ir_pin = ir_pin;
pinMode( this->ir_pin, OUTPUT);
}
void
NikonRemote::pulse_on( unsigned long duration ) {
unsigned long stop = micros() + duration;
while( micros() < stop ) {
digitalWrite( this->ir_pin, HIGH );
delayMicroseconds( 13 );
digitalWrite( this->ir_pin, LOW );
delayMicroseconds( 13 );
}
}
void
NikonRemote::pulse_off( unsigned long duration ) {
unsigned long stop = micros() + duration;
while( micros() < stop );
}
void
NikonRemote::click() {
for (int i=0; i < 2; i++) {
pulse_on(2000);
pulse_off(27850);
pulse_on(390);
pulse_off(1580);
pulse_on(410);
pulse_off(3580);
pulse_on(400);
pulse_off(63200);
}
}