Okay I got this idea for a Bluetooth enabled universal remote controlled via an iPhone. From my initial research it looks like I should use an Arduino Leonardo with this shield
I hooked up a IR receiver and IR emitter to a breadboard and connected it to an Arduino Uno rev3 with an ethernet shield (pictured). IR receiver was used to capture the codes and emitter was sending them to devices that are to be controlled and the system works great for Apple Remote.
But then I tried recording Sony codes from a remote and every time I pressed a button my IR receiver would show a different code (I'm using the IRremote library). Another problem: Ethernet shield is using a lot of energy so I hope your solution with a low power Bluetooth module will be better.
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.
#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;
}