loading
Picture of Arduino All-In-One Remote

Now you can have all the remotes of your house in a device that fits in your hand with Arduino, never fight for who has the TV remote again!

To make it you will need:

  • Arduino (I used a cheap copy of the arduino UNO).
  • LCD keypad shield, (I bought mine from dealextreme)
  • 1x Infrared LED (standard ~940nm)
  • 1x Infrared sensor.
  • A computer. (That can run the arduino compiler program)

Codes/Programs:

  • Program for gathering signals (download here)
  • Main program (download here)
  • Video program (download here)
 
Remove these adsRemove these ads by Signing Up

Step 1: Intro:

Infrared light has been used quite a lot for many different applications in many fields, one of them is communication, specifically between remotes and domestic devices, what allows us to control them without leaving the comfort of our sofa.

The process of communication between an emitter (the remote) and a receiver (the device) starts when the user presses any button of the remote, this device has an oscillator and a preconfigured chip that allow the signal to adopt a square waveform with a frequency of 39kHz, depending on the button pressed, the chip will use a determined signal code.
This signal travels through the circuit until it reaches the infrared LED, which transforms it into a series of pulses of invisible light (~940nm). If any sensor it's in it's range those pulses will be transformed into a quadratic wave that will indicate what to do according to the programming of the device.

To create a remote we want to capture those pulses, which will have a certain amplitude in time, we also want to know the time between those pulses so we can reproduce those pulses with voltage and time as the only variables.

Step 2: The hardware.

Picture of The hardware.
pin headers.png

In this instructable we won't need to work hard creating complicated circuits, instead, our work will be centered on the code we are going to implement.

The hardware we are going to use is the Arduino and the LCD keypad shield, which will help to visualize the menu that will order the codes by their function and the remote they come from .

Notice that this shields usually come without the pin headers, without them we won't be able to use the pins that remain free.
If your shield don't has them just go to your local electronics store and buy a female pin header, cut it and sand the edges with sandpaper, then just solder them into place.

We will use 2 different setups depending on whether we want to gather of send the codes:

Step 3: Gathering the codes.

Picture of Gathering the codes.
DSC_1106.jpg
TSOP1838-pins.png
6.png

Before we can create a functional remote we will need to gather the codes of the remotes we want to use, we will use an infrared sensor to do so.

To set up the circuit, we can follow the sketch in the pictures, connecting the signal pin of the sensor to the pin 2 and the other pins to 5V and ground.

The code we will be using is from an Adafruit tutorial, I made some changes in order to make our job easier.

Now comes the boring part, once the code has been uploaded and the sensor connected we go to "Tools" and we click on "Serial Monitor". You will see a message that says "Ready to decode IR!", now, by pressing any key of the remote while facing the sensor, we will be able to obtain the code.

If you use the version I provided the readings will appear in a code form ready to be pasted and interpreted by the Arduino main program, we just need to take care of storing this code to avoid losing it, to do so we can open a .txt to paste and label this signals now converted into code.

IMPORTANT: the program reads the time the signal is high as well as it is low, before you send the signal the program is already counting the time it is low, that time will appear as the first reading and it is useless so it must be deleted. Also, many of the code is unnecessary since it's repeated to make sure the device get's it, if you can find a pattern I suggest you to cut the code and save space, if you just copy and paste it all it's OK but you might be pasting too much redundant information.

TIP: If the Arduino compiler show this message "Serial port 'COM3' not found. Did you select the right one from the Tools > Serial Port menu?" your Arduino isn't connected or the port isn't recognized.


Once we have all the codes we want we can move on to the next step.


Step 4: Preparing our code: menus and submenus

Picture of Preparing our code: menus and submenus
2.png
3.png
4.png
5.png

Before being able to send the codes we need to visualize what are we sending, we will need to create a menu with all the functions (or submenus) we want to use.

Creating a menu it's easy, but it can be quite confusing, I've added lots of comments about the functions of each part in the main code.

I would have liked to use a library but instead I built it all in a single monolithic program so you don't have to download anything else, that way it's easier to learn how it works, creating a menu is quite useful and a must-learn task for every programmer.

Menus:

Once you open the code file, the first thing you want to look for the code that appears at the first image surrounded by a green square, this constants limit the domain of the menus and submenus, to specify the number of menus you want to create you have to take into account there will be a menu 0, meaning that if we input a 2, the program expects to have three menus.

See the third picture to make yourself an idea of how the limits work, basically, if you try to read an array that doesn't exists because it's out of the domain, the program will notice it and will return you to the original position.

Once this has been done, you have to specify the name of the menus at the menu char array (see picture 2), the code is designed to have three menus, but you can add as many as you want by repeating the structure of the 4th image and making the corresponding adjustments in the array and in the domains.

Submenus:

The submenus will be all contained in a single array, so you must write the functions of each menu in the submenu array, then you have to specify the limits of these submenus at code surrounded by the green square, of course if you add or remove menus you have to add or remove this constants.

The codes:

The program is designed to track your position in the menu/submenu array, for example, if you change of menu, it's variable will also change, that way, when you press the select button you are sending the menu and submenu indexes, in which you are, to the code sending function so it can chose between a series of cases to find the code that matches that function inside the menu.

To put the codes you just have to copy and paste the code obtained when reading the remote signals to the corresponding menu and submenu cases. (see picture 5), you have to pay attention so the function index matches the case number or your remote will be a chaos.

Once you have finished with all this save it and you'll have your very own remote code.

Step 5: Testing it.

Picture of Testing it.
DSC_0473.jpg
rivh4y.jpg
DSC_0674.jpg

Once you've finished with the code it should be able to work, make sure you place the infrared LED from digital pin 3 to ground, pin 3 is a PWM pin, other pins won't work.

Left and right buttons control the menus, up and down control the submenus, select sends the code attached to the corresponding submenu inside the menu.

If you want to have much more power and range you can use several LED's and use a transistor as shown in the picture. I say this because the power supplied by a digital pin is limited to 40mA, enough to lit one or two LED's but not enough to lit an array of 5 LED's for example.

The resistor value for the base (middle pin of the transistor) should be around 1-2k.

Due the high frequency switching a resistor may not be needed since the LED's will handle the power. (I've tried this myself with a standard IR LED and a 5V supply from the digital pin 3 with no problems)

TIP: If you want check if it works you can see the IR light by using a digital camera.

If you have any questions or comments I'll be glad to hear them.

Thanks for watching and don't forget to vote :)

Victor8o5 (author) 1 year ago

I've just added a video of it working, I know that feel when you view an instructable of a cool thing just to realize there's no video :(

If you want to download the code the Arduino was using while I was recording the video I've added another link at the beginning.

marsekal1 month ago

good mr

stuff like this takes a lot of time to develope and to publish, and you did it. you are a good human being. thanks for your effort and for share it. thanks.

RobertoF36 months ago

Hello, thank you for the project. I was reading it and I've lost one info: where are they stored so many strings of remote codes? I ask it, because Arduino has only 512 bytes of NVRAM available.

Victor8o5 (author)  RobertoF35 months ago

I can't answer your question because I'm still in my second year of EE and I still need to learn how this chips work internally. I've done some tests with all the remote codes implemented and I can't seem to induce some kind of memory fail.

All I know is the maximum storage seems to be 32256 bytes.

Hi,

This looks like an excellent project.

I downloaded your code today and became a little confused. How can recorded high pulse become transmitted low periods?

The infra red gathering signals code appears to put high going pulses into array element pulses[currentpulse[[0] :

if ((highpulse >= MAXPULSE) && (currentpulse != 0)) {
printpulses();
currentpulse=0;
return;
}
}
// we didn't time out so lets stash the reading
pulses[currentpulse][0] = highpulse;

In the printpulses subroutine this leads to setting a delay command from the high pulse duration :

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

So this implies a delay for high pulses and command pulse ir, for low ones:

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

In the remote final version download pulseIR takes the infra red led high with a cyclic period of 20ms, for a period equal to the measured low time

void pulseIR(long microsecs) {
cli();
while (microsecs > 0) {
digitalWrite(IR_led, HIGH);
delayMicroseconds(10);
digitalWrite(IR_led, LOW);
delayMicroseconds(10);
microsecs -= 26;
}
sei();
}

Am I missing something obvious?

A little research and the mystery is solved..
.
The sensor remains high until it detects modulated infra red, then it outputs low.

To quote from the adafruit link you gave for your IR receiver:
.
"IR detectors are digital out - either they detect 38KHz IR signal and output low (0V) or they do not detect any and output high (5V)."

.
I built the project and recoded to define low going pulses as IR received. I fine tuned the lcd menu code and added a device specific variable to control the carrier frequency.

.
The setup works well. I was able to control all the devices I had, except for a Panasonic plasma- I read somewhere that panasonic uses a very specific carrier frequency of the order of 36.7 kHz. This suggests that the transmitted signal needs to be very accurate. Has anyone got the system to work with a 42 inch Panasonic plasma?

Thanks for the inspiration!

.

cliff_top.jpgcliff_front.jpg

What if I used an MSP430 Texas Instrument? Is it possible to use the same codes/sketch? Will it be okay?

Victor8o5 (author)  luna.winternight9 months ago

I've never seen that board before, I guess if it can't be uploaded with the arduino IDE probably not, since the program would need to be adapted to work with new compilers (the ones that the MSP430 uses) because they'll probably wont be able to recognize functions like delay();, millis(); and so on..., so you would have to "translate" the program so the compiler can read it and finally upload it.

If it can, some minor adjustments when setting the pins might be needed since I've seen the pins have a different arrangement.

#Victor8o5

I have 2 questions
1- Is the resulted pulses dependant on the IR-LED that is connected to the LCD KEYPAD SHIELD (i use IR.LED.WHITE.5MM ) ?
2- Is the pulse that results from the original remote variable for the same button ?

Victor8o5 (author)  mohamed.aboshosha.73910 months ago

I don't think I've fully understood the question but I'll do my best:

The LED is a standard 900nm IR, any other LED won't work, similar IR LED's may also work. The LED emits the pulses thanks to the code, the LCD keypad is just for inputting and visualizing the program and it has nothing to do with the performance of the LED since the 3rd pin isn't used by it. You can add more IR LED's switched by a NPN transistor and connected directly to 5V to increase the range of the remote.

When recording the pulses from the original remote the times recorded may change slightly, this is caused by precision errors but they won't affect the overall working of the remote. The original remote has a certain IR signal for every button, as the arduino has an specific IR signal for every sub-menu.

amr3211 months ago

What is the meaning of [avrdude: stk500_getsync(): not in sync: resp=0x00]. it happen after uploading the read signal ir code and this comment show up.

Victor8o5 (author)  amr3211 months ago

I think there might be a problem with your Arduino connection, check if you selected the good board and if the connections are OK.

amr3211 months ago

what kind of infared sensor you use? is it IR Sensor Set or

Digital Infrared Sensor
Victor8o5 (author)  amr3211 months ago

It's this one, these kind of sensors are widely used in household appliances, they have one lead for 5 volts and one for ground. When an infrared beam hits it the first pin goes HIGH (talking about logic), they are very fast, allowing to capture remote signals by a series of HIGHs and LOWs.

Sorry for the delay.

fantastic! i'm about to try it out. but what is the black box at the bottom of the arduino? where can i get it? thank you!

Victor8o5 (author)  niqueryptic1 year ago
It's a home made case made out of wood, it has a hollow space inside to store two 9v batteries and a switch to control the power, here's a pic of it. Sadly I didn't take any photos when making it so I can't do an instructable about it.

Also thank you guys for your support!
temp_-1376065939.jpg

thanks! is there anywhere i can your complete codes for this project? i'm really having a hard time figuring it out. it would be really helpful to have some guidance. thanks!

Victor8o5 (author)  niqueryptic1 year ago

Codes are at the beginning of the instructable, just before the "Intro" step, at the "To make it you will need:" list.

I'll make it more visible since some people have also asked about the program.

mrfixit631 year ago

Hello, I was wondering, How can I use this idea to control something that I don't have the remote for? I'm having great difficulty finding proper code, and ways to get code from the internet and use them on my Arduino. I was using https://github.com/shirriff/Arduino-IRremote with http://www.remotecentral.com/cgi-bin/mboard/whichremote/thread.cgi?1887 which gave me no results after weeks of trying. (It doesn't help that I'm not a skilled programmer, either.) The device that i'm trying to control is a Sony BDV-E370 blue ray home theater system that I picked up at a yard sale for 5 bucks :D Anyways, I want to use it properly, without having to buy a replacement remote (Which Amazon.com won't sell to me, because I live in Canada, and Amazon.ca don't have it.). Thanks for reading, I really hope you look into this, keep in touch with me, and have a nice day! :)

Best way to find a code for a device with no remote is to search the web. Doing a google search with Sony BDV-E370 ir codes shows this page as first result, which actually contains the whole list of codes for the remote:

http://www.remotecentral.com/cgi-bin/mboard/whichr...

Hope it helps!

I've searched high and low on google for codes, but none of them worked on the arduino.

Victor8o5 (author)  mrfixit631 year ago

As sourcery said you can find the codes on the internet, the bad thing is they come with rare formats to be used with universal remotes, usually this codes are contained in hexadecimal formats, I'm unaware about the possible interpretation and implementation to use with the Arduino program I've made since it's designed to work with natural numbers.

It would be better to buy an universal remote and upload the files, if you wanted to use the Arduino you would have to pass the hex code to integers that represent the times of the signal and then encase them into the functions of the program, what would be a very tedious task.

Thank you for some feedback, i'm probably just going to go for the universal remote, because that's Waaaaaaay too advanced for me to do. I've tried to use the hex codes in the code, but no luck. I gave up on trying it.

dorton1 year ago

Hi Victor,

I'd suggest putting those codes in ROM, then just loop through them. It will reduce you program length and make it easier to read.

eg:

const int IRCmd1[] = {4440, 4400, 540, 1660, 520, 1660, 540, 1660,520, 560, 540, 560, 520, 560, 540, 560,520, 580, 520, 1660, 540, 1660, 520, 1660,540, 560, 520, 560, 540, 560, 520, 560,540, 560, 520, 580, 520, 1660, 540, 560,520, 560, 540, 560, 520, 560, 540, 560,520, 580, 520, 1660, 520, 580, 520, 1660,540, 1660, 520, 1660, 540, 1660, 520, 1660,520, 1680, 520, 0};

case x: i=0;

do {

pulseIR(IRCmd[i++]);

delayMicroseconds(IRCmd[i++]);

} while IRCmd[i];

Victor8o5 (author)  dorton1 year ago

Thanks, I thought about that when I was programming the remote program, I've been breaking my head to make something alike because when you run the code the operations that have to be made (++, finding and reading the array...) add time to the whole operation of sending a signal I still don't know if that delay caused by these operations could be negligible or it could cause the remote to malfunction, C is one of the fastest programming languages but taking into account the speed of the processor I'm not sure about if that code could cause problems.

I thought about counting the time with millis() between the beginning and the end of the operation and then subtract it from the delays.

Another thing I had in mind was some sort of conversion to an hexadecimal format to save space. At this point this would require libraries to keep it all clean and neat and to avoid going insane.

Space is not too much of a problem since a charged remote program doesn't takes more than 1/3 or to 1/2 of the memory of the Arduino, but I must say it's a very good habit to think wisely and try to minimize the weight of the program whenever it's possible.

I'll work on it and I'll try to upload a new version with new features, maybe even recording code on the go.

Thanks for bringing this up.

Had another look, (clearly I'm having fun). If you look at the IR libs on the Arduino site, they use an int on change interrupt and a timer to measure the pulse width. This is a good way to measure the incoming pulse widths.

To send pulses out, setup your LED output (ie pin D2) with "tone(PIN2, 38000);" then just use "DDRD |= ~4" to turn it on and "DDRD |= 4" to turn it off.

Victor8o5, I think this is a great Instructible and wonder if you could attach the complete code that you used ? I would like to see the menus and sub menus with your IR commands . Your code description sounds logical I have tried using a menu system before , but with my limited skills I was not able to get it to run.

Thank you so much for sharing ,

Build_it_Bob

I just found the link to the code ...I will start looking through it now .

Thanks again !

Build_it_Bob

DoItOrDie1 year ago

Excellent! This is just what I have been needing.

jgall21 year ago
Just finished making this project just have to put it in a box and all done. Excellent instructable, great project. If anyone is wanting to do this project I would recommend just using Victor8o5's code and pasting in the ir code gathered in the spots where it is supposed to go.
wilgubeast1 year ago

You individually read the IR signals from all of your remotes??? You win the remote control patience award. A device designed for the lazy, turned into something worthy of a monk. A lazy monk, but a monk nonetheless.

As someone who gets frustrated programming my Logitech Harmonies, this is glorious. The remote control singularity. Now it just needs a case.

Victor8o5 (author)  wilgubeast1 year ago

Yeah, It might be a bit tedious, but it's the simplest way, I guess it's not that bad, you just point the remote to the sensor, press a button and the code gathering program will encase the times in functions for you, so you just have to copy and paste that block of functions in its corresponding case.

It's quite fast actually, recording 10 buttons doesn't takes you more than 3 minutes.

And yes, I can feel the irony, just the main code took me several weeks of programming.

what kind of arduino you use?

Victor8o5 (author)  amr321 year ago

Its a copy of the Arduino UNO, called "freaduino" it works exactly the same, same pins, same disposition, same power, same code... but is has the chip embedded on the pcb and some extra features like a 3.3 to 5 switch to chose the output of the digital pins, it also has svg pins.

You won't have any problem if you use the code with your original Arduino UNO.

I love it. Anyone with the patience to fully solve this problem deserves a medal. Like the guy who made an end grain coffee table in his apartment without clamps. Or the girl who made a chainmaille shirt with needlenose pliers and poptabs. You rock, dude.

Enjoy the year of pro membership that comes with the feature, and I'm setting you up with 3 bonus months of pro to gift to someone else. Or for yourself, as I won't be following up. :D

^ like
Ok I'm 8 and I know how to program so come to me
Victor8o5 (author)  jack 8 years old1 year ago

Wow! I was 16 when I started programming.

simotoni1 year ago

Bravissimo !!!