45 Minute Project – £4.10 XBMC Remote Receiver

I’m a big fan of XBMC, and have an Ouya running XBMC set up in my lounge, streaming from my NAS. I normally use XBMC remote on my phone for controlling it, but this gets annoying when the phone is on charge, or I’m using it for something else.

I noticed that the majority of my TV remote is completely unused when the TV is in HDMI mode, and had a bit of a lightbulb moment!

Remote
Almost none of these buttons are used!

I already had an Arduino Pro Micro (£3) lying about i’d bought for testing out as an upgrade path for the minimus based projects i’ve been playing with.  It is leonardo compatible, small, cheap and pretty easily available.  I added an IR Receiver (£1.10) to the weekly Hackspace Farnell order to complete the parts list.

The pinout of the IR receiver makes it very easy to connect to the pro micro, using the RAW (VUSB), GND, and A3 pins.  I just bent the OUT pin (pin 1) on the receiver to the left a bit as follows:

Front Back

 

The body of the receiver fits perfectly behind the USB plug, flat against the voltage regulator.  I used the IRremote arduino library to grab data from the remote using the IRrecvDemo sketch and mushed some buttons:

8B452AD
FFFFFFFF
FFFFFFFF
8B410EF
FFFFFFFF
FFFFFFFF
FFFFFFFF
8B4D22D
FFFFFFFF
8B4926D
FFFFFFFF
FFFFFFFF

My remote uses 0xFFFFFFFF as a ‘key repeat’ code, about every 200ms when the button is held down. I found that in practice I had to ignore the first of these, as it was repeating way too fast and doing double presses.

I tweaked the IRrecvDemo sample code, added in a bit of keyboard and came up with some working code:

#include

int RECV_PIN = A3;

IRrecv irrecv(RECV_PIN);

decode_results results;

int key;
int count;

void setup()
{
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    switch (results.value)
    {
      case 0x8B452AD: // up
        key = KEY_UP_ARROW;
        count = 0;
        break;
      case 0x8B410EF: // right
        key = KEY_RIGHT_ARROW;
        count = 0;
        break;
      case 0x8B4D22D: // down
        key = KEY_DOWN_ARROW;
        count = 0;
        break;
      case 0x8B4D02F: // left
        key = KEY_LEFT_ARROW;
        count = 0;
        break;
      case 0x8B4926D: // enter
        key = KEY_RETURN;
        count = 0;
        break;
      case 0x8B412ED: // red
        key = KEY_BACKSPACE;
        count = 0;
        break;
      case 0x8B4B24D: // green
        key = ' ';
        count = 0;
        break;
      case 0x8B44AB5: // yellow
        key = KEY_ESC;
        count = 0;
        break;
      case 0x8B450AF: // blue
        key = 's';
        count = 0;
        break;
      case 0xFFFFFFFF:
        count++;
        break;
      default:
        key = -1;
        break;
    }
    if ((key != -1) && (count!=1))  // if count = 1, it is the first key repeat, so ignore it.
      Keyboard.write(key);
    irrecv.resume(); // Receive the next value
  }
}

Total cost £4.10, total time 45 minutes. Sorted!

IMG_20140301_121939

thinkl33t

thinkl33t wrote 21 posts

Post navigation