iPhone controlled universal remote

Using a Sony TV Remote I get results like this - quite repeatable

The following is pressing the buttons 1-6 (the repeat codes represent what is being sent out the IR transmitter - the longer you hold it down the more it repeats) In my case a quick press generated 3 repeats.

1000000000000000100000000
1000000000000000100000000
1000000000000000100000000

1010000000000000100000000
1010000000000000100000000
1010000000000000100000000

1000100000000000100000000
1000100000000000100000000
1000100000000000100000000

1010100000000000100000000
1010100000000000100000000
1010100000000000100000000

1000001000000000100000000
1000001000000000100000000
1000001000000000100000000

1010001000000000100000000
1010001000000000100000000
1010001000000000100000000

Here is my simple script

#include <Arduino.h>
#include <IRremote.h>

// Receive on Digital Pin 4
int RECV_PIN = 4;

decode_results results;
int incomingByte = 0;
IRrecv irrecv(RECV_PIN);

void setup()
{

	/* add setup code here */
	Serial.begin(57600);
	Serial.println("Startimg....");

	irrecv.enableIRIn(); // Start the receiver


}

void loop()
{
	if (irrecv.decode(&results)) {
		int count = results.rawlen;
		
		// Skip the first byte - just a timing since last packet recevied.

		for (int i = 1; i < count; i++) {

			if (1==0)
			{

			if (results.rawbuf[i]< 10)
				Serial.print("  ");
			else if (results.rawbuf[i]< 100)
				Serial.print(" ");
			Serial.print(results.rawbuf[i]);
			Serial.print(" ");
			}
			else {
				if (results.rawbuf[i] == 8)
					Serial.print("0");
				else 
					Serial.print("1");
			}
		}		
		Serial.println("");
		irrecv.resume(); // Receive the next value
	}
}

In my code you will see it displays a binary 0 or 1 depending if the value is 8 or not. This could change depending on the device.

So to test that out change the code that says if (1==0) to if (1 == 1) in the script to use that section of the code which prints out the actual values read.

Special Note:

I have also modified the code in the IRRemote.cpp file in the IRRemote library to return values that do not change so much.

Basically when it saves values it calls this function to fix up the values to make them consistent.

unsigned int fixTimer(unsigned int t)
{
	if (t <  20)
		return 8;
	else if (t < 31)
		return 24;
	else if (t < 33)
		return 32;
	else
               	return t;
}

See http://wiki.crowe.co.nz/Mitsubishi%20Heat%20Pump.ashx to see what I changed.

This could explain why you are seeing different values - using the code on my wiki page I get consistent values of 8 and 24 on the Sony remote.

Chris