Ir remote control ac not work!

Hi, i need to remote control my a/c(brand Stelbi) from arduino. I have used the irremote library for decrypt the code from the remote(which is in raw) this is the output:

 3450,1750,400,1350,400,1350,400,450,400,500,400,450,400,1350,400,450,450,450,400,1350,400,1350,400,450,400,1350,400,500,350,500,400,1350,400,1350,400,450,400,1350,400,1350,400,450,400,500,400,1350,400,450,400,500,400,1350,350,500,400,450,400,450,450,450,400,500,400,450,400,500,400,450,400,500,400,450,400,450,450

and this is the sketch:

#include "IRremote.h"

IRsend irsend;

void setup()

{

Serial.begin(9600);

}

int khz=38; //NB Change this default value as neccessary to the correct modulation frequency

// ON and 2O C° with 1 FAN heat

unsigned heat[] = {3150,1650,550,1050,550,1000,550,300,550,300,550,350,550,1000,550,300,550,350,550,1000,550,1000,550,300,550,1050,550,300,550,300,550,1000,550,1000,600,300,550,1000,550,1000,550,350,550,300,550,1000,550,300,550,350,550,1000,550,300,550,350,550,300,550,300,550,350,550,300,550,300,550,350,550,300,550,350,550,300,550};



void loop() {

irsend.sendRaw(heat, sizeof(heat)/sizeof(int), khz);

delay(1000);



}

I have tried to transmit it but it doesn’t work…can you help me?

This could be a software or hardware problem.

You need to devise a method to determine if your hardware is working before you can think of debugging the software

I too have a project that I am building regarding IR remote control to power on/off my AC, based on the temp values. My problem is that I am trying to setup an interrupt so that it does not continuously send the power code to the ac unit once the condition has been met. Here is my latest revision of the code.

#include <math.h> //loads the more advanced math functions
#include <IRremote.h>
IRsend irsend;
int logicSwitch = 0;

void setup() { //This function gets called when the Arduino starts
Serial.begin(9600); //This code sets up the Serial port at 9600 baud rate
}

double Thermister(int RawADC) { //Function to perform the fancy math of the Steinhart-Hart equation
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celsius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius
return Temp;
}

void loop() { //This function loops while the arduino is powered
int val; //Create an integer variable
double temp; //Variable to hold a temperature value
val=analogRead(0); //Read the analog port 0 and store the value in val
temp=Thermister(val); //Runs the fancy math on the raw analog value
Serial.print(temp ); //Print the value to the serial port
Serial.println(" Farenheit");
Serial.println(logicSwitch);
if ((temp <= 80 ) && logicSwitch == 1) {
logicSwitch = 0; //Sets the logic switch to false
irsend.sendNEC(0x10AF8877, 32); // AC power code */
}
else if((temp >= 70) && logicSwitch == 0) {
logicSwitch = 1; //Sets the logic switch to true
irsend.sendNEC(0x10AF8877, 32); // AC power code */
}
delay(1000); //Wait one second before we do it again
}

Everything works fine between my AC unit powering on and off and the temp values are read and stored okay. However, the piece with the logicSwitch that I added as an interrupt, is not storing the 1 or 0 when the criteria is met. It just randomly spits out 1’s or 0’s. Any suggestions would be much appreciated.

JohnLincoln:
Could you have the signal inverted? i.e the LED is off when it is supposed to be on, and vice versa.

Could you post a circuit diagram of your circuit, please?

Does the wavelength of your Infra Red LED match the response of the AC's detector? (This shouldn't be the problem, but would affect the range).

I don't know the wavelength of my a/c!

Nevermind. Fixed this on my own. Had to modify the less than and greater than symbols :stuck_out_tongue:

#include <math.h> //loads the more advanced math functions
#include <IRremote.h>
IRsend irsend;
byte logicSwitch = 0;

void setup() { //This function gets called when the Arduino starts
Serial.begin(9600); //This code sets up the Serial port at 9600 baud rate
}

double Thermister(int RawADC) { //Function to perform the fancy math of the Steinhart-Hart equation
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celsius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Celsius to Fahrenheit - comment out this line if you need Celsius
return Temp;
}

void loop() { //This function loops while the arduino is powered
int val; //Create an integer variable
double temp; //Variable to hold a temperature value
val=analogRead(0); //Read the analog port 0 and store the value in val
temp=Thermister(val); //Runs the fancy math on the raw analog value
Serial.print(temp ); //Print the value to the serial port
Serial.println(" Farenheit");
Serial.println(logicSwitch);
if (temp >= 80.00 && logicSwitch == 0) {
logicSwitch = 1; //Sets the logic switch to true
irsend.sendNEC(0x10AF8877, 32); // AC power code */
}
else if(temp <= 70.00 && logicSwitch == 1) {
logicSwitch = 0; //Sets the logic switch to false
irsend.sendNEC(0x10AF8877, 32); // AC power code */
}
delay(1000); //Wait one second before we do it again
}