Introduction: Make Your Own IR Remote That Can Reach Anywhere
My home theater is far away from my bed and the remote is unreachable there. Many a time, I thought of controlling the home theater from my bed to enjoy music anytime (due to laziness of course). So, I did some search and found this great video from GreatScott. That video provided me enough information to get started. Then further, I taught myself the remaining things to send and receive IR codes from IR receiver and transmitter. After building this you'll be able to control anything that is unreachable from your spot, provided you have enough wires.
Step 1: Parts Required
Infrared receiver (any kind having three legs like TSOP38238)
Refer data sheet for pin out of your receiver using the number written on it.
Infrared transmitter LED
Short leg is cathode or ground.
Push buttons (number depends on how many functions of the device you want to control)
Ribbon Cable (as per your requirement)
Standalone Arduino circuit
Hot Glue Gun
Male and Female headers
Step 2: Basics
I first recommend you to watch GreatScott's video, link is provided in the introduction.
Now we know that every device manufacturer uses different hex codes to differentiate the signals and function accordingly. So, we just have to get those hex codes and transmit those with the help of IR led.
But, there are several protocols which device manufacturers follow. The protocol varies from device to device and from manufacturer to manufacturer. If we want the device to understand the code, we will have to follow that protocol and send the data accordingly. No need to worry, the Arduino library takes care of all that things. All you gotta do is to determine what protocol your device uses.
Before proceeding further, please read this explanation of various protocols and how they work from Adafruit.
Step 3: Determining the Protocol and Getting Hex Codes
Install the two libraries link of which is given in Step 1. Now go to examples, then IRLib-master and open IRrecvDump, upload the code to your Arduino. Connect the output of IR receiver to pin 11 after supplying the power to it with Arduino 5V and GND pin.
Now you are ready to determine the protocol of your device.
Open serial monitor. Point your remote to the receiver and press any button, a lot of things will pop up in the window. We only care about one thing, the first line.
The letters after "Decoded" is the protocol used. In my case it is NEC and "Value" is the hex code of that signal.
Now you know the protocol you have to use.
After this, you have to get the hex codes of different buttons you want to use. For that open IRrecvDemo from IRRemote in the examples. This will only give the hex codes of button pressed in serial monitor. Upload the code to Arduino and note down the hex codes of different buttons you want to used.
Note: The receiver is very sensitive and almost all light sources emit infrared rays that can get caught by the receiver which will interfere it's functioning. So to prevent that, keep the receiver in dark, otherwise you will get garbage in the serial monitor.
Step 4: Sending IR Codes
Connect an IR transmitter led in the pin 3 of the Arduino and the short leg in series with a 1K resistor to ground.
You can’t change the pin number for sending IR codes, the library doesn't allow it. You can only use pin 3 for this purpose.
Open IRsendDemo from IRLib-master examples folder. In place of "Sony" write the name of your protocol you decoded in the previous step. Notice the blue color while writing the name of the protocol. If it does not changes to blue, manipulate it, make some letter, make some small make something caps, something that makes sense. For NEC all letter has to be written in caps. In the second argument of the function My_Sender.send, write the decoded hex code after "0x". 0x tells the Arduino that code is in hexadecimal format. Leave the last argument as it is. It is the number of bits a protocol uses and generally 20 is OK. Learn more about that in the Adafruit PDF I mentioned.
But you are not ready just now to successfully send the codes.
Step 5: Finding the Receiver Location of Your Device
For the device to successfully catch the codes you sent, you have to point the IR led directly to the receiver, inside the device. It will be generally behind a thin material, like a glass or a film or something, something through which IR rays can pass through, not behind some solid material like the covering. To find the receiver, play with your originally provided remote, to get an estimate of the receiver location. Then bring your IR led connected with Arduino in front of it. Open serial monitor, wave your IR led in front of the device where you estimated the receiver will be while pressing the enter key. This is because according to the code we uploaded, the Arduino will only send the codes if it receives a letter in the Arduino serial monitor.
You'll find a place soon, where the device responds to all your codes perfectly and you'll feel very happy, I know :D.
Step 6: Going for a More Permanent Setup
After prototyping, it's time for some planning to permanently setup the whole thing.
The remote: I used a perforated board to make the remote. I used 6 push buttons with 1K pull down resistors, and soldered 4 meter long ribbon cable to it. The push button circuit will be installed right next to my bed, while the other end will be connected to micro controller board. Also I added male headers to the other end for convenience.
The transmitter: I made a stand with the help of GI sheet. You can use your own idea for mounting the IR led to the device. instead of soldering wires to the LED, I decided to use female that can be removed easily. In the other end, I again used male headers.
Future plans: I'm thinking to add a standalone arduino circuit to the assembly. It will be more practical instead of whole Arduino Uno and will be cost effective. The headers attached will help here. I can use a female header to connect with the standalone Arduino.
Also I have planned to add another push button which will control the relay that will be used to turn on or off the main power supply for the device.
Step 7: Final Problems and Drawbacks
After using it for some hours, I noticed the speaker turns on/off automatically, switches to another mode on it's own or increases or decreases volume on it's own, meaning there was false triggering. This maybe due to noise generated for some reasons.
To remove this, I decided to use another push button with same 1K pull down resistor. The only difference will be, the pins will function only if that push button gives high input to the micro controller, else ignore them. The program is pretty simple. I've attached mine for you guys to get an idea. This reduces false triggering to very large extent and this effect is almost negligible. Now the circuit is working perfectly.
1. The circuit will become impractical if you want to use from far away as there is requirement of really long cables.
Solution: There is another sketch that uses an IR receiver to receive the signals from the remote and sends the received code with an IR transmitter. Meaning the sending and receiving is done in the same program. I've not tested it yet, in a glance, it looked a little complex to me.If I make it work, I'll create another instructable on it. And if it did, it will be very efficient as only three wires will be required from your place to the micro controller and you will be able to use any signal on your remote.
2. The circuit uses too much arduino pins for a simple purpose.
Solution: It's just a concept I thought of. It's like multiplexing Suppose there are 7 push buttons connected to 7 pins of Arduino. We are using 5 push buttons to send IR codes to the IR led. The other two are used for multiplexing. If the first pin is high from the two, the five pins will a different code when pressed, and when the other from the two is high, the set of five push buttons will send another set of codes. Hence we are able to send ten different codes using only 7 pins.
Well, that's all !
I've attached pictures I took during prototyping. This will help you a little, I think.
Please comment if any problem.
Thanks for reading :)