The first step in in deciding which keys can be used is determining what, if anything, each key sends. Although this information appears early in the project, it is about the last thing you find out. The decoder has to be functioning before you can tell what is being sent. To get all of the codes, I put a Serial.print() in the timerISR() routine to print the address and command every time a button was pressed. It gets messy, because there are misreads - more on some keys than on others. I think the cheap remote may have contributed something to that problem. Some keys read correctly 100% of the time, while others misfire every third time. I didn't have that problem with the Cox cable remote, but it would polute the signal by echoing in a different protocol. Actually, the decision to change was ultimately made because the volume up/down signals would go three or four times, then the protocol would change to the cable box protocol for three or four echoes, then back. I couldn't get a smooth fade. Eventually, it would signal an error on the Aux, and switch from Aux to TV. Hopefully a bug in the controller.
There must be a list of Sony remote codes somewhere, but I haven't been able to find one. With this little project, you will be able to make one easily enough. You just have to do the above trick for every Sony code number on a couple of universal remotes to get most of them. Luckily I needed to do that only twice for this SIRC project.
| One Sony TV code | ||
| Addr | Cmd | Function |
| 1 | 37 | Input |
| 1 | 96 | Menu |
| 1 | 18 | Vol+ |
| 1 | 19 | Vol- |
| 1 | 20 | Mute |
| 1 | 58 | Info |
| 1 | 59 | Last |
| 1 | 116 | Up |
| 1 | 117 | Down |
| 1 | 51 | Right |
| 1 | 52 | Left |
| 1 | 0 | 1 |
| 1 | 1 | 2 |
| 1 | 2 | 3 |
| 1 | 3 | 4 |
| 1 | 4 | 5 |
| 1 | 5 | 6 |
| 1 | 6 | 7 |
| 1 | 7 | 8 |
| 1 | 8 | 9 |
| 1 | 9 | 0 |
| 1 | 17 | Ch - |
| 1 | 16 | Ch + |
| 1 | 101 | Ok |
| 1 | 14 | Guide |
| 1 | 20 | Mute |
An interesting thing about the address. Don't count on it always being the same. Any given button always sends the same address, but different buttons may send different addresses. There appear to be 5 different addresses in use on the Cox remote, and they seem to be grouped more-or-less by function. Other multi-function remotes seemed to do that also, but I didn't find a manufacturer's remote that behaved that way. To simplify things, though, I spent $10 on a GE universal remote. I set it up as a Sony TV, and all of the keys send the same address.
We should decide exactly what we want to do with the codes received. In the real world the codes would be mapped to functionality - some would pulse a line, some would set or reset a line, or some would change an analog voltage, or the code sent to an I2C potentiometer. Because the ATmega328 can pulse width modulate the voltage on an LED, I have chosen to simulate the volume control up/down function in that way. Other buttons, specifically 1 and 2, will turn LED's on while 4 and 5 will turn them off.
Not all remote control transmitters work the same. Some will resend the code up to three times in a short period of time for a single button push. Some will send the code once. All will repeat the code if the button is held down. The Sony protocol expects the message to be repeated every 45 mS. To prevent that from affecting the system, a command should be allowed to lock out further input until it has completed, if it so chooses.
The remote control runs entirely in the background. Commands will be presented to the main loop ("userville") and a flag indicates the arrival. The main loop will look for this flag and when set, will read the command. The address, and extra data are available as well, but the address will always be the address we set it to look for. It may be changed programmatically.
The code will be presented in the form of an Arduino library. An Arduino is not required, but the environment is, along with an ATmega88,-168, or -328. The code doesn't care which. You also don't need the Arduino bootloader in your chip, if you have an ISP, but I'll leave that to you to figure out.