All The Good Ones Were Taken

TV Infra-Red Remote Control Transceiver

The "big" television chez nous is a Samsung LE40M86. It's old, but it works, and blissfully pre-dates all that "smart" nonsense.

I can't remember the last time we watched actual broadcast television on it. It just has a variety of game consoles and media playback devices plugged into its many inputs. And there's the rub. The only way to select one of these many inputs is the button labelled SOURCE on the remote control, which tells the TV to switch to the next input. But the TV does this really... really... slowly. Going from one HDMI to the next can take a good five seconds, and rotating through the whole set of inputs can take the better part of half a minute.

It would be really helpful if the remote control had buttons to select inputs directly, but it doesn't. Which is annoying, because it turns out the TV is capable of doing so, but the remote control just doesn't have the right buttons. What it does have are a group of media buttons — record, rewind, stop, play/pause and fast-forward — which the TV itself ignores.

Close-up of TV remote control showing buttons labelled as described above

Enter this widget. It monitors the infra-red signals from the remote control, and when it sees that one of those five media buttons has just been pressed, it sends out its own IR signal to the TV instructing it to switch to the corresponding input.

Various electronic components in a small breadboard

I've left it on a breadboard rather than soldering something more permanent board, so I can easily reuse the parts when the TV finally dies.

Implementation

Here's the circuitry:

Electronic circuit schematic

C source code will be available here sooner or later. But honestly, if you're looking for code for your own projects, you're much better off with a library like Arduino-IRremote. My code has some room for improvement: it busy-waits for a signal rather than using interrupts, the pulse length measurement doesn't account properly for loop overheads, and the gadget very occasionally becomes unresponsive for a minute or so and I haven't figured out whether it's a hardware or software problem yet.

Signal Encoding

The infra-red signal is transmitted on a 38 kHz carrier, as an initial leader followed by 32 bits of data.

The leader is a 4500µS mark, followed by a 4500µS space. Then there's a 600µS mark for the start of the data.

Each data bit is a space of roughly 600µS for 0 or 1700µS for 1, followed by a mark of 600µS.

I've assumed that data is delivered least-significant bit first, as this leads to a more logical grouping of codes. The first 16 bits are the device ID; for my TV that's 0x0707. The next 8 bits are the control code, and the final 8 bits are the inverse of the control code.

Samsung TV Codes

The control codes that the Samsung LE40M86 accepts are as below. Those in bold weren't on the remote and were discovered though experimentation.

1st\2nd digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 DUAL SOURCE POWER Sleep Timer Off 1 2 3 Vol.Up 4 5 6 Vol.Down 7 8 9 MUTE
1 Ch.Down 0 Ch.Up PRE-CH Green Yellow Blue MENU Ana­logue TV INFO
2 PIP -/-- SUB­TITLE P.MODE TEXT/MIX EXIT
3 TV/DTV P.SIZE
4 STILL REW STOP PLAY/PAUSE FF REC GUIDE
5 RETURN
6 Up Down Right Left ENTER/OK VGA CH.LIST Red
7 VCR CABLE TV DVD STB
8 Off Ext1 SVideo Compo­nent Next HDMI D.MENU
9 DTV.Ch.Up AnyNet Off On
A
B HDMI2
C HDMI3
D
E 4:3 16:9 HDMI1 Ext2 AV
F