Arduino Based TV Remote ProjectTags: arduino, diy, atmega328p, infrared
It Could Use a Nice Wooden Enclosure; the Altoids tin Works for Now.
A couple years ago my TV remote broke. I had used one of those universal remote phone apps as an alternative for a while, but that just got really frustrating. Without the tactile feel of buttons it was too easy to press wrong buttons on my smart phone; accidentally pressing mute, stop or changing the channel / input, etc. I considered just ordering a cheap replacement remote off of Ebay for a few dollars but part of me wanted to take advantage of the situation and make one from scratch using the atmega328p chip used on the famous Arduino Uno. I had been tinkering with the atmega chip quite a bit at the time and was also exploring the process of designing circuit boards using cad software. I loved the idea of designing a circuit board from scratch & filling it with circuits. This seemed like the perfect project for me – being able to use my beloved arduino chip, design and populate a circuit board with circuits & fashion some kind of project case (altoids tin) to put it all in. I went for it.
The Fabricated PCB from Oshpark
II. Circuit Design w/ Eagle CAD
I started researching cad software for circuit design & looking for easy tutorials for beginners. I came across this awesome introduction to Eagle Cad. I tinkered with this tutorial for a bit until I realized how possible this endeavor is. The concepts of writing custom “schematics” and “circuit design” started to feel much more approachable. I went ahead and gave it a shot. I had prototyped a version of the TV remote on a couple breadboards for testing. I wrote some C++ code along-side using amazing arduino libraries like, KeyPad for helping catch the button presses within the button matrix.
Some Prototypes & Experimentation
III. Hasty Circuit Design & Problem Solving
As for the battery circuit I did a little research and decided to use an Ebay Chinese made lithium battery charger module. Basically it’s a little board with a micro-usb/chip that regulates the charging of the battery. On another note, the Infrared LED circuit was tough to figure out. I added a NPN transistor to try and amplify the IR LED output. It works pretty good but could be a bit stronger. This circuit should have been designed into the board but wasn’t. I also messed up one of the atmega 328p chip terminals and wired it wrong in the design schematic. Both issues were corrected using some jumpers/external circuitry. It is interesting to note that the atmega chip uses an internal precise clock to generate the IR frequency. Basically, in code you send a pulse to one of a few designated pins that are internally configured to work with this internal clock. In my haste, I accidentally routed the wrong pin (pin 7) to the IR Led in Eagle. When I received the circuit boards after fabrication, I was able to just use a jumper to fix it.
Jumper Wires / IR LED Amplifier Circuit
IV. The Finished Project / Conclusions
Finished Project - Universal Remote 7000
Unfortunately the battery runs dead about every 2 weeks with normal use. I’ve implemented power saving code & power saving techniques but haven’t been able to do better than that with this particular setup. I’ll have to tinker more in order to solve the power issues but for now it works great. Everything is secured to an altoids tin pretty well with some rubber bands. It’s not the prettiest build but it works well. Ideally it would be built within some custom oak wood enclosure - I look forward to one day learning carpentry.
V. Infrared & the Electromagnetic Spectrum
Image Courtesy of Wikipedia
This is probably the thing that was the most fascinating to me. Infrared communication is an old technology that we often take for granted. Infrared has a longer wavelength and sits right below the visual spectrum making it perfect for communication. You basically have a “sender” & a “reciever”. The reciever LED usually is configured to only listen to a certain predefined frequency pulse - in this case 38KHz (or 38,000 pulses a second). This helps filter out unwanted IR signals. Each button on the TV remote is defined as a particular byte - or a series of 8 pulses run 38,000 times a second. The receiver senses the pulses as a series of 1’s & 0’s making up a byte, and passes this information to the TV to be decoded / interpreted (i.e. “volume up”). Being so intrigued by this I created a reciever module of my own and experimented with sending / recieving & interpretting my own packets of bytes. I wrote my own “protocol” and sent text from one IR module to another. It was really cool to see first hand how all this works. It led me to tinker with / investigate other types of signal communication - “long wave” / “short wave” radios, blue-tooth communication; & also the other end of the spectrum - ultraviolet, etc. This project is in itself worth further exploration in a post so I’ll save it for another time. If interested to learn more about IR communication, SparkFun has a very good tutorial on the subject that I highly recommend reading.
“Universal Remote 7000”.