I'm a newbie with my arduino uno, and I want to try to decode my Panasonic AC remote, but I hit a bit of a roadblock now.
I try to control my LG tv, and it works just fine either the receiver or the emitter, but I can't do the same with my AC.
I use IRremote library for this, here's the receive sketch I use
Code: Select all
//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>
//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);
//+=============================================================================
// Configure the Arduino
//
void setup ( )
{
Serial.begin(9600); // Status message will be sent to PC at 9600 baud
irrecv.enableIRIn(); // Start the receiver
}
//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->address, HEX);
Serial.print(":");
}
// Print Code
Serial.print(results->value, HEX);
}
//+=============================================================================
// Display encoding type
//
void encoding (decode_results *results)
{
switch (results->decode_type) {
default:
case UNKNOWN: Serial.print("UNKNOWN"); break ;
case NEC: Serial.print("NEC"); break ;
case SONY: Serial.print("SONY"); break ;
case RC5: Serial.print("RC5"); break ;
case RC6: Serial.print("RC6"); break ;
case DISH: Serial.print("DISH"); break ;
case SHARP: Serial.print("SHARP"); break ;
case JVC: Serial.print("JVC"); break ;
case SANYO: Serial.print("SANYO"); break ;
case MITSUBISHI: Serial.print("MITSUBISHI"); break ;
case SAMSUNG: Serial.print("SAMSUNG"); break ;
case LG: Serial.print("LG"); break ;
case WHYNTER: Serial.print("WHYNTER"); break ;
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
case PANASONIC: Serial.print("PANASONIC"); break ;
case DENON: Serial.print("Denon"); break ;
}
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpInfo (decode_results *results)
{
// Check if the buffer overflowed
if (results->overflow) {
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
return;
}
// Show Encoding standard
Serial.print("Encoding : ");
encoding(results);
Serial.println("");
// Show Code & length
Serial.print("Code : ");
ircode(results);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpRaw (decode_results *results)
{
// Print Raw data
Serial.print("Timing[");
Serial.print(results->rawlen-1, DEC);
Serial.println("]: ");
for (int i = 1; i < results->rawlen; i++) {
unsigned long x = results->rawbuf[i] * USECPERTICK;
if (!(i & 1)) { // even
Serial.print("-");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
} else { // odd
Serial.print(" ");
Serial.print("+");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
}
if (!(i % 8)) Serial.println("");
}
Serial.println(""); // Newline
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode (decode_results *results)
{
// Start declaration
Serial.print("unsigned int "); // variable type
Serial.print("rawData["); // array name
Serial.print(results->rawlen - 1, DEC); // array size
Serial.print("] = {"); // Start declaration
// Dump data
for (int i = 1; i < results->rawlen; i++) {
Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
if (!(i & 1)) Serial.print(" ");
}
// End declaration
Serial.print("};"); //
// Comment
Serial.print(" // ");
encoding(results);
Serial.print(" ");
ircode(results);
// Newline
Serial.println("");
// Now dump "known" codes
if (results->decode_type != UNKNOWN) {
// Some protocols have an address
if (results->decode_type == PANASONIC) {
Serial.print("unsigned int addr = 0x");
Serial.print(results->address, HEX);
Serial.println(";");
}
// All protocols have data
Serial.print("unsigned int data = 0x");
Serial.print(results->value, HEX);
Serial.println(";");
}
}
//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results)) { // Grab an IR code
dumpInfo(&results); // Output the results
dumpRaw(&results); // Output the results in RAW format
dumpCode(&results); // Output the results as source code
Serial.println(""); // Blank line between entries
irrecv.resume(); // Prepare for the next value
}
}
Code: Select all
Encoding : UNKNOWN
Code : 9DCF5C22 (32 bits)
Timing[131]:
+3450, -1700 + 450, - 400 + 450, -1300 + 450, - 400
+ 450, - 400 + 450, - 450 + 450, - 400 + 450, - 400
+ 450, - 400 + 450, - 450 + 400, - 450 + 450, - 400
+ 450, - 400 + 450, - 400 + 450, -1300 + 450, - 400
+ 450, - 400 + 450, - 450 + 450, - 400 + 450, - 400
+ 450, - 400 + 500, - 400 + 400, -1300 + 450, -1250
+ 450, -1300 + 450, - 400 + 450, - 400 + 450, -1300
+ 450, - 400 + 450, - 400 + 450, - 450 + 400, - 450
+ 450, - 400 + 450, - 400 + 450, - 400 + 450, - 450
+ 400, - 450 + 450, - 400 + 450, - 400 + 450, - 450
+ 450, - 400 + 450, - 400 + 450, - 400 + 450, - 450
+ 400, - 450 + 450, - 400 + 450, - 400 + 450, - 400
+ 450, - 450 + 450, - 400 + 450, - 400 + 450, - 400
+ 450, - 450 + 400, - 450 + 450, - 400 + 450, - 400
+ 450, - 450 + 400, - 450 + 450, -1250 + 450, -1300
+ 450, - 400 + 450, - 400 + 450, - 400 + 450, - 450
+ 400, - 450 + 450
unsigned int rawData[131] = {3450,1700, 450,400, 450,1300, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,1300, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 500,400, 400,1300, 450,1250, 450,1300, 450,400, 450,400, 450,1300, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,450, 450,1250, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 450}; // UNKNOWN 9DCF5C22
I got a very different result
Code: Select all
Press the button on the remote now - once only
Raw: (439) 3496, -1728, 448, -424, 448, -1292, 448, -420, 448, -424, 448, -420, 452, -420, 456, -412, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 452, -420, 448, -1288, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -1288, 452, -1288, 452, -1288, 452, -420, 452, -420, 448, -1288, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -416, 452, -420, 452, -420, 452, -416, 452, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -1288, 452, -1292, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -11016, 3496, -1724, 452, -420, 448, -1292, 448, -420, 452, -420, 448, -424, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 448, -424, 448, -420, 452, -420, 448, -1292, 448, -420, 476, -396, 448, -420, 452, -420, 448, -424, 448, -420, 448, -420, 452, -1288, 452, -1292, 448, -1292, 448, -420, 452, -420, 448, -1292, 476, -396, 448, -420, 448, -420, 452, -420, 452, -420, 472, -396, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 452, -1288, 452, -1288, 448, -1292, 448, -1292, 448, -1292, 452, -1288, 452, -420, 448, -420, 452, -420, 448, -1292, 448, -420, 448, -424, 448, -420, 452, -1288, 452, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -1288, 452, -1288, 452, -1288, 452, -1292, 448, -1292, 448, -420, 452, -1292, 448, -420, 448, -1292, 452, -420, 448, -420, 452, -420, 448, -420, 448, -424, 448, -420, 448, -424, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -420, 452, -420, 448, -424, 448, -420, 452, -1288, 448, -1292, 452, -1288, 452, -420, 448, -420, 428, -444, 448, -420, 452, -420, 424, -444, 428, -444, 424, -448, 424, -444, 428, -1312, 428, -1312, 452, -1288, 452, -420, 428, -444, 424, -472, 400, -468, 428, -444, 428, -444, 428, -440, 428, -440, 460, -412, 460, -408, 464, -408, 492, -380, 488, -380, 492, -380, 492, -376, 496, -376, 496, -1216, 524, -372, 500, -372, 500, -368, 500, -372, 496, -376, 496, -372, 500, -1212, 528, -372, 496, -372, 500, -372, 500, -368, 500, -372, 496, -372, 500, -372, 500, -372, 496, -372, 500, -1212, 524, -1216, 528, -372, 496, -372, 500, -372, 496, -376, 496, -372, 496, -1216, 524, -1216, 524, -376, 496, -1216, 524, -372, 496, -376, 496, -372, 496, -376, 496,
This is the sketch I use to send
Code: Select all
/*
* IRremote: IRsendRawDemo - demonstrates sending IR codes with sendRaw
* An IR LED must be connected to Arduino PWM pin 3.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*
* IRsendRawDemo - added by AnalysIR (via www.AnalysIR.com), 24 August 2015
*
* This example shows how to send a RAW signal using the IRremote library.
* The example signal is actually a 32 bit NEC signal.
* Remote Control button: LGTV Power On/Off.
* Hex Value: 0x20DF10EF, 32 bits
*
* It is more efficient to use the sendNEC function to send NEC signals.
* Use of sendRaw here, serves only as an example of using the function.
*
*/
#include <IRremote.h>
IRsend irsend;
void setup()
{
}
void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol
unsigned int irSignal[131] = {3450,1700, 450,400, 450,1300, 400,450, 400,450, 450,400, 450,450, 400,450, 400,450, 450,400, 450,450, 400,450, 450,400, 400,450, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,1300, 450,1250, 450,1300, 450,400, 400,450, 450,1300, 450,400, 450,400, 450,400, 450,450, 400,450, 400,450, 450,400, 450,400, 450,450, 450,400, 450,400, 450,400, 450,450, 400,450, 400,450, 450,400, 450,450, 400,450, 450,400, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,450, 450,400, 450,400, 450,450, 400,1300, 450,1250, 450,450, 450,400, 400,450, 450,400, 450,450, 400}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz); //Note the approach used to automatically calculate the size of the array.
delay(5000); //In this example, the signal will be repeated every 5 seconds, approximately.
}
I try using different IR libraries, but it just messing up my arduino IDE, so I revert back to IRremote. So, like I said earlier, this is kind of a roadblock for me. Don't know what else to do, so I wanna try to calm my head for now and ask here in the forum what is it that I did wrong.
Thank you again for the help.