forked from thijsbekke/Arduino_IR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIRTransmitter.cpp
More file actions
37 lines (27 loc) · 1.08 KB
/
IRTransmitter.cpp
File metadata and controls
37 lines (27 loc) · 1.08 KB
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
/*
* IR library v1.0.0 (20141122) made by Thijs Bekke https://github.com/thijsbekke
* See IRTransmitter.h for details.
* Fork of https://github.com/adafruit/Nikon-Intervalometer
* License: GPLv3. See license.txt
*/
#include "IRTransmitter.h"
IRTransmitter::IRTransmitter(int IRledPin) {
_IRledPin = IRledPin;
pinMode(_IRledPin, OUTPUT);
}
void IRTransmitter::pulseIR(long wait, long microsecs) {
delayMicroseconds(wait);
// we'll count down from the number of microseconds we are told to wait
cli(); // this turns off any background interrupts
while (microsecs > 0)
{
// 38 kHz is about 13 microseconds high and 13 microseconds low
digitalWrite(_IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds
digitalWrite(_IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}