How to control your TV with an Arduino!

 by Wally_Z
So. This Instructable will show you how to control anything controllable by IR, or Infrared light.

This includes cameras, TV's, DVD players, VCR's, you get the point.

I will be showing you how to receive the codes, and then how to transmit them.

Objects required for this project:
1x Arduino (any kind as long as it has whats called "PWM" which I will explain)
1x IR LED (you can get these from any TV remote)
1x IR reciever (see picture)
1x USB A to B wire for programming the Arduino
1x Computer to program the Arduino with
1x Arduino software
and the .PDE files I will include

This website really helped me out a lot with this. http://www.ladyada.net/learn/sensors/ir.html

THIS IS NOT MY CODE, I DO NOT CLAIM OWNERSHIP. I merely copied and pasted the code and rewrote the instructions to make this easy to understand. 

IF YOU DO ANYTHING ILLEGAL WITH THIS CODE I WILL NOT BE HELD RESPONSIBLE (which I think is probably not a problem).

 
Remove these adsRemove these ads by Signing Up

Step 1: Preparing to Receive Signals

First you want to get the IR LED Receiver mentioned in the introduction.

You can get one here: http://www.adafruit.com/products/157
They cost $2 not including shipping and handling.

So you want to hook up the receiver according to the first picture.

I highly suggest putting both the IR Receiver and the remote in a shoe box or something that is dark (the same shoe  box of course). This will insure there will be the least amount of interference and to have clearer code so you don't have to program your Arduino 12 times for one simple task. Also, make sure you are out of the way of people watching TV.

And you want to download the file named IR_RECORD.PDE and open it into the Arduino program.

Plug your Arduino in with the USB cable I hope you have and proceed to step 2!
matt.e.jenkins says: Dec 15, 2011. 11:30 AM
You can get the IR Receiver from just about any old VCR, TV, DVD player, anything that had a normal IR remote. I have a hand full of those sensors that I took from all the old broken devices i have laying around. Thanks for the tutorial.
Wally_Z (author) in reply to matt.e.jenkinsDec 15, 2011. 6:50 PM
You're welcome! Show this to your friends and see what they make!
Eduort says: Apr 15, 2013. 11:10 AM
This IR Reciver can work whit this? https://arduino-info.wikispaces.com/file/view/IR-Receiver-AX-1838HS.pdf
chetan1oct93 says: Dec 25, 2012. 11:28 PM
I didnt understand the timing thing. the code sends a 38kHz pulse. i.e one pulse takes around 26us. and the serial monitor shows atfirst 36328 usec, 280 usec.
so that means u giving 280us to void pulseIR(). which means there would be 10 pulse send to receiver. so does it means it goes 10 channels up??? If yes what about ur 20 sec delay??
Wally_Z (author) in reply to chetan1oct93Dec 26, 2012. 12:16 AM
I'm not quite sure what you're asking. Would you mind retyping it in a way I might be able to understand?

I'm not trying to be offensive; it's just the way you worded it is a little weird.
hhokka says: Dec 5, 2012. 12:43 PM
Yes! that's just what i meant, i am making a little remote with 4 buttons vol+/- and channel up/down, i sure would accept some help with the code :>

And Thank you very much for your time, Great that there are nice people like you! :)
hhokka says: Dec 4, 2012. 8:26 AM
Hi!
Thanks for this great tutorial! working really well, but i have a question how can you make this work with a manual switch?.
Wally_Z (author) in reply to hhokkaDec 5, 2012. 9:06 AM
If you mean making it send the code by pressing a button, then yes. It's not that hard.

All you have to do is in "void loop" is to make it check if the button is being pushed, and if it is, send out the IR code once. Make sure to debounce the button either through software, or a resistor hooked up to ground. (Check the "button" example in the Arduino IDE)

To make life even easier, you could define each remote send command as a class, and call each class when you push different buttons. It'll work just like a regular remote that way, and make your life a bit easier.

If you need help with either of the above, feel free to contact me and I will definitely help you out.
c1c2c3 says: Oct 7, 2012. 3:01 AM
Do you need a resistor to go to the IR led?
Wally_Z (author) in reply to c1c2c3Dec 5, 2012. 9:01 AM
Not if you hook the IR LED up to pin 13. Pin 13 on MOST arduino's already has a resistor on it. If you're not sure if it has a resistor, you should use a 100ohm just to be safe.
rodrrj says: Dec 3, 2012. 7:23 AM
When clicking on the IR_RECIEVE.PDE and the IR_SEND.pde with Internet Explorer both open in a new window. However, IR_RECIEVE.PDE opens in a different format - one that cannot be cut/pasted into an Arduino sketch and verified with Arduino. As a work around, I used Firefox which is tons more forgiving than IE. Interestingly enough, both PDEs open the same way with Firefox.
KevCarrico says: Oct 26, 2012. 2:50 PM
great project!

i modified the serial output in the RECEIVE sketch so that it can be directly copied and pasted into the SEND sketch already formatted:

------
Serial.print("delayMicroseconds(");
Serial.print(pulses[i][0] * RESOLUTION, DEC);
Serial.print("); ");
Serial.print("pulseIR(");
Serial.print(pulses[i][1] * RESOLUTION, DEC);
Serial.println(");");
------

jabujavi says: Jun 24, 2012. 7:22 AM
I have a questions.
Why use delayMicrosecond and don't simply delay? The value of delay is in ms, is not?
carlos.camposalcocer in reply to jabujaviJul 18, 2012. 7:26 PM
ms=milliseconds
us=microseconds
jabujavi in reply to carlos.camposalcocerJul 19, 2012. 1:30 AM
FAIL ¬¬
Thanks, I work with us many times and in this case didn't see it...
cmartinez4 says: May 23, 2012. 2:38 PM
Do you need a resistor for the IR receiver?
wmain says: May 1, 2012. 8:50 PM
You could define a typedef as

typedef struct irCode {
int off;
int on;
} codes[34];

codes[0] = {36328, 280};
.
.
.
codes[33] = {700, 240};

then use this code to send it

for (cx=0; cx<34; cx++) {
delayMicroseconds(codes[cx].off);
pulseID(codes[cx].on);
}

dudesurge says: Dec 18, 2011. 10:30 PM
i love is, i tore apart an old ball mouse and got some IR-LEDs but the receivers didnt quite work as well as i'd hoped so i ripped one i knew would work out of a vcr and the led from the mouse worked but its so dim is has to be pretty close but im gonna tare apart the remote that went with the vcr, but im rambling again, i do have a question, did u write a code to control multiple buttons? im sure its not to hard to do as ive been working with my arduino for a few weeks now but if its already out there id prefer not to go thru the hassle
Computothought says: Dec 4, 2011. 5:19 AM
Hmmm, gives me an idea for a laptop project.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!