Thanks everybody for all the help, I got it working. Here I am posting the modified code so others can control their Champion swamp cooler via Arduino.
Again, Thanks everybody.
emm386
/* Code modified by Scott M.
This code can control a Champion Swamp Cooler's via IR:
1. Turn blower to high, low, or off
2. Turn water pump on or off
3. Turn entire unit on or off
I plan to use photocells enabling detection of cooler switching from high to low or
pump being on or off. Final project will use a few RHT03 Humidity & Temp sensor's enabling cooler
to operate more efficient.
Special thanks are in order for:
Website providing original code:
ladaya.net - Provided initial source code
Labview Programmer:
Frank S. - Labview specialist
Arduino.cc forum users:
johnwasser
cunctator
johnnycanuck
Original programmer's information and link follows:
*/
// This sketch will send out a Nikon D50 trigger signal (probably works with most Nikons)
// See the full tutorial at http://www.ladyada.net/learn/sensors/ir.html
// this code is public domain, please enjoy!
int IRledPin = 13; // LED connected to digital pin 13
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the IR digital pin as an output:
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop()
{
Serial.println("Sending IR signal");
PowerCooler();//Turns entire swamp cooler on or off, requires minimum of 2 sets of code
PowerCooler();
delay(10000);//Delay, easier for troubleshooting.
PowerFan();//Switches fan from High, Low, and off
PowerFan();
delay(10000);
PowerPump();//Switches pump on or off
PowerPump();
delay(10000);
}
// This procedure sends a 38KHz pulse to the IRledPin
// 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(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
}
void PowerFan() {
int p = 545;//p is used for both transmissions and delays, represents a period of time.
int dp = p*2;//Provides double the value pf p
int dly = p*14;//used as a spacer between IR transmissions
//IR Signal, Switches fan (High, Low, Off)
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
delayMicroseconds(dly);
}
void PowerCooler() {
int p = 545;
int dp = p*2;
int dly = p*14;
//IR Signal, Turns Cooler on and Off
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dly);
}
void PowerPump() {
int p = 545;
int dp = p*2;
int dly = p*14;
//IR Signal, Turns pump on or off
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(p);
delayMicroseconds(dp);
pulseIR(dp);
delayMicroseconds(p);
pulseIR(p);
delayMicroseconds(dly);
}