Air conditioner IR remote control

I followed this tutorial:

I got the code from my working remote:
rcvdONOFFcodes.pdf (21.5 KB)

I then used this code to upload to the Mega with just the IR LED and transistor, cause I dont want the temp regulation bit:


#include <IRLibSendBase.h>    //We need the base code
#include <IRLib_HashRaw.h>    //Only use raw sender
#include <dht.h>

#define dht_apin A0 // Analog Pin sensor is connected to
 
dht DHT;

IRsendRaw mySender;

void setup() {
  Serial.begin(9600);
  delay(2000); 
  while (!Serial); //delay for Leonardo
  Serial.println("DHT11 Humidity & temperature Sensor\n\n");
}

#define RAW_DATA_LEN 228
uint16_t rawDataOn[RAW_DATA_LEN]={
  4154, 1602, 606, 1226, 606, 1226, 594, 410, 
  606, 406, 606, 402, 602, 1226, 602, 406, 
  598, 410, 602, 1230, 602, 1226, 594, 414, 
  602, 1230, 602, 406, 574, 434, 578, 1250, 
  574, 1258, 570, 438, 578, 1226, 602, 1230, 
  602, 406, 598, 410, 602, 1226, 606, 402, 
  602, 410, 602, 1226, 606, 402, 602, 406, 
  606, 402, 598, 410, 606, 402, 598, 406, 
  610, 398, 602, 406, 606, 402, 602, 406, 
  598, 410, 602, 406, 598, 410, 602, 406, 
  574, 434, 570, 434, 578, 430, 574, 1230, 
  602, 406, 606, 402, 602, 1230, 602, 406, 
  606, 402, 602, 1226, 602, 1230, 602, 406, 
  598, 410, 602, 406, 598, 410, 602, 406, 
  598, 406, 606, 1226, 606, 1222, 610, 398, 
  602, 1230, 602, 406, 598, 410, 602, 406, 
  598, 410, 570, 438, 578, 430, 570, 434, 
  582, 430, 570, 410, 602, 406, 598, 410, 
  602, 406, 598, 406, 606, 402, 602, 406, 
  606, 402, 602, 406, 606, 402, 602, 406, 
  606, 402, 602, 406, 594, 410, 602, 406, 
  598, 410, 602, 406, 598, 410, 602, 406, 
  578, 430, 570, 438, 578, 430, 570, 438, 
  578, 430, 570, 410, 606, 402, 598, 410, 
  602, 406, 598, 406, 606, 402, 602, 406, 
  606, 402, 602, 406, 606, 402, 602, 406, 
  606, 402, 602, 1226, 606, 1226, 602, 1226, 
  606, 402, 602, 406, 598, 410, 602, 1226, 
  606, 402, 578, 1000};

#define RAW_DATA_LEN 228
uint16_t rawDataOff[RAW_DATA_LEN]={
  4150, 1602, 578, 1254, 578, 1254, 578, 402, 
  602, 406, 606, 406, 598, 1230, 602, 406, 
  606, 402, 602, 1230, 598, 1230, 602, 406, 
  606, 1226, 606, 402, 602, 406, 606, 1226, 
  594, 1234, 598, 410, 606, 1226, 602, 1226, 
  598, 410, 602, 410, 594, 1234, 598, 410, 
  570, 438, 574, 1258, 574, 406, 606, 430, 
  574, 406, 606, 402, 602, 406, 606, 402, 
  602, 406, 606, 402, 602, 406, 606, 402, 
  602, 406, 606, 402, 602, 406, 594, 414, 
  598, 406, 598, 410, 602, 406, 598, 410, 
  602, 406, 578, 430, 574, 1230, 598, 410, 
  606, 430, 570, 1230, 602, 1230, 602, 406, 
  606, 402, 602, 406, 606, 402, 602, 406, 
  606, 402, 602, 1226, 606, 1226, 606, 402, 
  598, 1234, 598, 410, 602, 406, 598, 410, 
  602, 406, 598, 410, 594, 410, 602, 406, 
  574, 434, 570, 438, 574, 434, 582, 402, 
  598, 410, 606, 398, 602, 406, 610, 398, 
  602, 406, 606, 402, 602, 406, 606, 402, 
  602, 406, 598, 410, 606, 402, 598, 410, 
  602, 406, 598, 410, 602, 402, 598, 410, 
  574, 434, 578, 430, 574, 434, 578, 430, 
  574, 434, 578, 402, 602, 406, 606, 402, 
  602, 406, 606, 402, 602, 406, 606, 402, 
  602, 406, 606, 402, 602, 406, 606, 398, 
  602, 406, 610, 1222, 598, 1230, 602, 406, 
  606, 402, 602, 406, 594, 414, 582, 1250, 
  570, 438, 574, 1000};

void loop() {
    mySender.send(rawDataOn,RAW_DATA_LEN,36);//Pass the buffer,length, optionally frequency
}

Here is the wiring:

But nothing happens when I turn on the mega near the IR recevier of my a/c. I just noticed there is no reference to pin 3 in code, is that from the library? Any suggestions?

It looks like the library uses IR_SEND_PWM_PIN and it varies based on which board you're using.

Try printing it.

You mean by doing this inside loop();

Serial.println(IR_SEND_PWM_PIN);

I get an out of scope error. Im guessing you mean in one of the library files. I tried in the IRLibSendBase.cpp inside the IRsendBase() but I get nothing in the serial monitor. I dunno where else to add it.

Ok so I couldnt find where to have it print out, but i trial and error-ed it and got pin 10.

Ok so now I know it works. I have to find a way to make it work now at least for on and off, which is by far what I use the most. So I was thinking of 2 push buttons, because its what i have. In which case I would wire the 3.3V to point where i would split out to 2 different buttons and have each button send out a different code. But then I got to thinking, the button is the same one on the original remote, so how do I manage that in code and wiring so that I only use 1 button?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.