Go Down

Topic: Arduino to send IR codes (Read 11009 times) previous topic - next topic


Jan 18, 2009, 11:11 pm Last Edit: Jan 18, 2009, 11:32 pm by agentsmith Reason: 1
I'd like to make Arduino to send IR codes to control various devices, but so far I only found projects about receiving IR codes.

I think it would be enough an IR emitter and a resistor... the tough part is the sketch :D

Does anyone have an idea on how to write it?

It would be good to use LIRC codes so it could be universal in practice.

Example LIRC code:

LIRC code syntax

Found this discussion,
but can't understand the ir pulses format used for GetIRkey and SendIRkey subroutines. There are no examples of keys plus I don't have a IR receiver right now to catch them :(



As far as I know, you can't send IR info in LIRC format. The 2nd link you provided has a Flags sections that shows the IR protocols LIRC understands.  You'd need to write (or find) a sketch that can output an IR signal that conforms to one or more of these protocols. Which one(s) should you use? That depends on the various devices you want to control. You may find that one device understands RC5 while another uses SIRC (Sony stuff mostly) or then again they might use an entirely different protocol.  

The 2nd post in the  forum link you provided will take you to a discussion (and sketches!) of the Sony and RC5 (also known as Manchester encoding I believe) protocols. You'll find both receive and transmit stuff there.  I'm using the Sony receive code I found there to help me add IR capability to a wired Creative Megaworks 250D remote :D




Hello Veronica,
thank you for the reply!!

For IR transmission you just use an IR led connected to a digital output, right?

Well I'd like to control my air conditioner units by mimicking their IR remote controls pulses. I think they use a custom coding for sending complex parameters like the temperature, the timer settings etc... that's why I looked for a way to get codes from LIRC files.

Anyway, seems it's better to catch the codes by myselft using a receiver.. on LIRC website there's a long list with some odds... do you have one to suggest that you're using?


I've been playing with IR quite a bit lately... To do short range remote control you can use just the IR LED and resistor. I started out using code from http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ and info from http://www.sbprojects.com/knowledge/ir/ir.htm


Jan 21, 2009, 12:29 pm Last Edit: Jan 21, 2009, 12:30 pm by agentsmith Reason: 1
Thanks Phizone for the links!

I checked the first one, and he used an oscilloscope which costs 120 dollars. Really cheap for an oscilloscope (even it's software powered) but expensive for my DIY project.
I can't understand the correlation between the oscilloscope readings and the four numbers he got to simulate the commands.

Since the oscilloscope way to catch commands is ruled out, and I don't know at which frequency my IR remote modulates...
There are instructions for use an Arduino as a low res oscilloscope (i wonder if it can detect modulation freq.) or a solar cell connected to an audio card (i think it has more resolution). What can I do?


You have all the tools you need with the arduino. Set up a photo diode (or transistor) and use pulse in to measure what modulation you have. You will see bigger numbers coming out but that is only the gaps between codes. Then filter out the the modulation (hardware or software) and count the bigger numbers. These represent the gaps. Any command will consist of a number of bursts on for xmS off for ymS. You don't have to know what the numbers mean or even if you have repeated something in the sequence just repeat those numbers and play it out.
That's how I did it anyway back in 92, it was a different computer but the principal is the same.
Look here at the June issue:-


Thank you Mike for sharing your experience. Wow a 1992 web page!

The only problem is how to achieve software demodulation... I have no clue on how to do that, but I'll try, maybe the solution comes up while looking at the numbers....

I think things would be much easier if I use this thing http://it.rs-online.com/web/search/searchBrowseAction.html?method=searchProducts&searchTerm=TSOP1738&x=0&y=0 but who knows if it's 38 kHz or something else :)


Is it suitable this photo diode to detect the IR modulation of remote controls?


I could easily see the IR signals from my remote by hooking up an IR photodiode to my sound card mic input and using a sound card oscilloscope program such as xoscope.  The resolution is sufficient to easily see the data pulses, but not to see the modulation.  (It probably doesn't matter a whole lot if it's 38KHz or 40KHz modulation in any case.)  The sound card oscilloscope isn't as good as a Tektronix TDS5034B oscilloscope, but it's about $12,000 cheaper  :)

Go Up