Download the sketch or copy and paste the below code into the Arduino IDE.
// This program allows an Arduino Uno to power on and circulate a Lasko 5538 Ceramic Heater.
//
// Usage: Attach an IR led (TSAL7400), but i believe any 940nm 5MM irled will work.
// Arduino Uno pin 13 -> resistor -> annode of ir led. Ir led cathode to ground.
// Calculate correct resistor value by using this formula. VCC – Vf / If = resistor value
//
// Credits: Rick Osgood, Adafruit
// Modified by Arduino Enthusiast
//
// Modify these lines to to fit your needs: 18, 68, 152, 159, 160
// For lines 17 and 67 you’ll input the raw codes that you want to run.
#define IRledPin 13
#define NumIRsignals 96
#define NumIRsignalsx 120
int IRsignal[] = {
130, 34,
130, 36,
46, 122,
130, 36,
130, 36,
46, 122,
46, 124,
46, 122,
44, 126,
46, 122,
48, 122,
130, 688,
128, 36,
130, 34,
48, 122,
130, 34,
128, 40,
44, 124,
46, 122,
48, 122,
46, 122,
48, 122,
46, 122,
132, 684,
130, 36,
128, 36,
48, 120,
130, 36,
130, 36,
46, 124,
46, 122,
46, 124,
46, 122,
46, 122,
48, 122,
130, 688,
130, 34,
130, 36,
46, 122,
130, 36,
130, 36,
46, 122,
46, 124,
46, 122,
48, 122,
46, 122,
48, 122,
130, 0};
int IRsignal2[] = {
130, 36,
130, 34,
48, 120,
130, 36,
130, 36,
46, 124,
46, 122,
46, 122,
130, 36,
48, 122,
46, 124,
46, 774,
130, 34,
132, 34,
46, 122,
130, 36,
130, 36,
46, 122,
48, 122,
46, 122,
130, 38,
46, 122,
46, 122,
48, 772,
130, 34,
132, 34,
46, 122,
130, 36,
130, 36,
46, 122,
48, 122,
46, 122,
130, 36,
48, 122,
46, 122,
48, 774,
130, 36,
128, 36,
46, 122,
130, 36,
130, 36,
46, 122,
46, 124,
46, 122,
130, 36,
48, 122,
46, 122,
46, 774,
130, 34,
130, 36,
46, 122,
130, 36,
128, 36,
48, 122,
46, 124,
46, 122,
130, 36,
46, 122,
48, 122,
46, 0};
void setup(void) {
pinMode(IRledPin, OUTPUT);
digitalWrite(IRledPin, LOW); //Make sure LED starts “off”
Serial.begin(9600); //Initialize Serial port
}
void loop() {
// buttonState = digitalRead(buttonPin);
// pinMode(buttonPin, INPUT);
char data[6];
int index = 0;
delay(1000); //Serial input seems to need some kind of short delay or the data gets screwed up.
while (Serial.available() > 0) { //Loop if there data on the serial line
if (index < 5) { //Make sure we don’t overflow
data[index] = Serial.read(); //Load a character into the string
index++; //Increment the index to get the next character
}
}
data[5]=’\0′; //Null terminate the string
delay (10000); // 10 second delay before turning on heater
// if (buttonState == HIGH) {
for (int i = 0; i < NumIRsignals; i+=2) { //Loop through all of the IR timings
pulseIR(IRsignal[i]*10); //Flash IR LED at 38khz for the right amount of time
delayMicroseconds(IRsignal[i+1]*10); //Then turn it off for the right amount of time
}
delay(5000); // Wait 5 seconds before running next code. Next code will run the raw code for circulate.
// delay(20*60000); // Wait 20 minutes until the next code will run. Keeps the heater on for 20 minutes
for (int i = 0; i < NumIRsignalsx; i+=2) { //Loop through all of the IR timings
pulseIR(IRsignal2[i]*10); //Flash IR LED at 38khz for the right amount of time
delayMicroseconds(IRsignal2[i+1]*10); //Then turn it off for the right amount of time
}
delay(40*60000); // Wait 40 minutes before looping.
data[5]=’\0′; //Clear the data
// } //Otherwise do nothing!
}
// This function allows us to PWM the IR LED at about 38khz for the sensor
// Borrowed from Adafruit!
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(IRledPin, HIGH); // this takes about 3 microseconds to happen
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
digitalWrite(IRledPin, LOW); // this also takes about 3 microseconds
delayMicroseconds(10); // hang out for 10 microseconds, you can also change this to 9 if its not working
// so 26 microseconds altogether
microsecs -= 26;
}
sei(); // this turns them back on
}