Last active
December 19, 2015 16:29
-
-
Save loisaidasam/5984238 to your computer and use it in GitHub Desktop.
IR Blaster based on http://learn.adafruit.com/ir-sensor/making-an-intervalometer and the results of https://gist.github.com/loisaidasam/5984107 on my A/C controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int blasterPin = 12; | |
int blinkLedPin = 13; | |
int hangoutTime = 7; | |
int sleepTime = 5; | |
void setup() { | |
// initialize the IR digital pin as an output: | |
pinMode(blasterPin, OUTPUT); | |
pinMode(blinkLedPin, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
Serial.println("\nSending IR signal"); | |
digitalWrite(blinkLedPin, HIGH); | |
sendIRCode(); | |
digitalWrite(blinkLedPin, LOW); | |
Serial.print("Sleeping for "); | |
Serial.print(sleepTime); | |
Serial.println(" seconds"); | |
delay(sleepTime*1000); | |
} | |
// This procedure sends a 38KHz pulse to the blasterPin | |
// for a certain # of microseconds. We'll use this whenever we need to send codes | |
void pulseIR(long microsecs) { | |
// 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(blasterPin, HIGH); // this takes about 6 microseconds to happen | |
delayMicroseconds(hangoutTime); // hang out for 7 microseconds | |
digitalWrite(blasterPin, LOW); // this also takes about 6 microseconds | |
delayMicroseconds(hangoutTime); // hang out for 7 microseconds | |
// so 26 microseconds altogether | |
microsecs -= 26; | |
} | |
sei(); // this turns them back on | |
} | |
void sendIRCode() { | |
pulseIR(8880); | |
delayMicroseconds(4360); | |
pulseIR(600); | |
delayMicroseconds(1580); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(1580); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(1600); | |
pulseIR(600); | |
delayMicroseconds(1580); | |
pulseIR(620); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(1580); | |
pulseIR(620); | |
delayMicroseconds(1580); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(1600); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(1580); | |
pulseIR(620); | |
delayMicroseconds(480); | |
pulseIR(620); | |
delayMicroseconds(1580); | |
pulseIR(600); | |
delayMicroseconds(1600); | |
pulseIR(580); | |
delayMicroseconds(1600); | |
pulseIR(620); | |
delayMicroseconds(1580); | |
pulseIR(620); | |
delayMicroseconds(1580); | |
pulseIR(600); | |
delayMicroseconds(1600); | |
pulseIR(600); | |
delayMicroseconds(500); | |
pulseIR(600); | |
delayMicroseconds(41280); | |
pulseIR(8860); | |
delayMicroseconds(2160); | |
pulseIR(600); | |
delayMicroseconds(28524); | |
pulseIR(8860); | |
delayMicroseconds(2160); | |
pulseIR(600); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment