I was 95% successful in getting my Arduino Uno microcontroller to read the keypressing of an Apple TV remote control. I say only 95% instead of 100% because it reads all the buttons, but only works reliably from a distance of a couple inches, so not so much "remote", more like only "mote".
I purchased a Radio Shack item 276-0142, a two piece container with an Infra Red Detector and Emitter. I have only played with the detector so far.
I had read about other people doing Arduino experiments with an infrared receiver, but when I got home from the Radio Shack store I discovered that their IR detector had two leads, and while the one in the online example had three. I couldn't find any Arduino plans online for a two lead IR detector so I had to kinda wander through several web sites to get where I am so far with the wiring and design. I did find plenty of user comments at the Radio Shack website about how this particular product was a piece of junk and didn't work at all. So I wasn't hopeful. But I finally made it function. I am not exactly sure if this is an optimal design, so any comments from other people would be welcome.
I got the basic Arduino code from www.instructables.com web site, particularly this one for the detector, and then modified it for interpreting Apple TV remote patterns of information.
http://www.instructables.com/files/orig/FJ8/0ZF4/GVQHPZ4H/FJ80ZF4GVQHPZ4H.pde
This is my wiring diagram
I noticed the pattern for an Apple TV's buttons had a bunch of values near 500-600 microseconds and another bunch around 1600, or about a 1:3 size ratio. These are for the off and on times in microseconds. I noticed there were 32 cycles of data between what appeared to be a much longer start and stop signals.
"usec" stands for microseconds
For the Middle Button of the remote
Received:
OFF ON
0 usec, 6380 usec
8900 usec, 4360 usec
560 usec, 540 usec
560 usec, 1620 usec
560 usec, 1620 usec
540 usec, 1620 usec
560 usec, 540 usec
560 usec, 1620 usec
560 usec, 1600 usec
580 usec, 1600 usec
560 usec, 1620 usec
560 usec, 1620 usec
560 usec, 1600 usec
560 usec, 540 usec
560 usec, 540 usec
560 usec, 520 usec
580 usec, 520 usec
560 usec, 1620 usec
560 usec, 1620 usec
560 usec, 540 usec
540 usec, 1620 usec
560 usec, 1620 usec
560 usec, 1620 usec
560 usec, 520 usec
580 usec, 1600 usec
560 usec, 540 usec
560 usec, 1620 usec
560 usec, 1620 usec
540 usec, 1620 usec
560 usec, 1620 usec
560 usec, 1620 usec
560 usec, 1620 usec
540 usec, 1620 usec
560 usec, 1640 usec
560 usec, 31000 usec
I noticed each button had a common start and ending, but then different in the middle of the data (the 3rd of 4 parts)
Menu Button: 32 560Wave: 1316411168
Play Pause: 32 560Wave: 131641141118
Left: 32 560Wave: 1316413148
Middle Button: 32 560Wave: 131642131118
Right Button: 32 560Wave: 13164458
Top Button: 32 560Wave: 1316431148
Bottom: 32 560Wave: 1316421248
So I recorded the incoming stream as a pattern of 32 bits of high and low ON, and examined the 8 bits starting with the 17th bit
The Play Pause button pattern 131641141118 translates to a signal pattern of:
0111011111100001 01111010 11111111
Example "If statement" (The array is zero based, so the 17th bit is in array pointer 16)
if (sigpattern[16] == 0 && \
sigpattern[17] == 1 && \
sigpattern[18] == 1 && \
sigpattern[19] == 1 && \
sigpattern[20] == 1 && \
sigpattern[21] == 0 && \
sigpattern[22] == 1 && \
sigpattern[23] == 0)
{
Serial.println("Play Pause Button");
}
Here is a screen shot from the Arduino - PC serial link showing the results as each button is pushed on the Apple TV remote control while pointed at the top of the IR detector on the Arduino breadboard:
So if someone could help me understand why it only works for a distance of a couple inches I would appreciate it. If I am veRy careful and move the remote perpendicular away from the detector I can get about six inches away, but I have to be veRy careful.
Special thanks to Wally_Z at instructables, see his web site: How To Control Your TV with an Arduino!
5 comments:
OH that all Looks a bit technical Mr ESB I will investigate tomorrow night I sadly have to go off and do technical things myself tomorrow . . . . . .
You gave me a headache.
That is scary technical Mr ESB. As for the problems of distance it can only be to do with sensitivity of the detector or you need to amplify the detected signal a bit before doing the decoding, maybe an op amp or the like or even something as simple as a reflector behind the infra red detector a bit like the reflector in a small torch for example. It might make it a little more directional sensitive but you might get further away.
Still it is early days and I am certain you will create a monster in no time......
fmcgmccllc: Ah, I wasn't even trying for headaches!
Rob: I have tried a few differenet Op Amp circuits but hasn't seemed to help. Late last night I finished drawing the circuit diagram for my latest try at an op amp enhancement. It worked a few times, but the range actuaLLy decreased. When I put the program in "fancy display" mode it just shows the simple successful button matchings, but the debug mode shows more detailed info showing the raw data even when it has a horrible signal. I gave up on that circuitry for now and I am now playing with a new internet interface and filesystem interface for the Arduino that I got in AmariLLo today. They are separate cards which I have to pay with separately for now until I do some hardware modifications. They are produced by the same company BUT incompatible with each other straight out of the box. Irritating ....
Hi, Many thanks for your information. It worked great :-) Now, for a better range with IR remote, I suggest you get your hands on a TSOP38238. These little thing do magic. They are built especially for IR remote and receive at about 20 feet. Have fun!
Post a Comment