Reading the IR signals is fairly easy. All you need is a IR receiver. The most commonly used infrared carrier signal is 38 kHz, but it should still work fine, if the receiver and sender use different frequencies.
Receiver:
I used IRremote library to send and receive infrared signals. You can download and read more instructions about IRremote library here.
Use the IRrecieveDump -demo to dump all the data read from your remotecontroller. If the data could be identified as RC5, Sony or NEC it will also be very simple to send.
To send IR, you need an Infrared LED with a resistor. You don't want to burn your LED so use this counter to calculate the best resistor for it.
IR-Led
Example:
Start the IRrecieveDump -demo and open serial monitor.
Point your remote towards the receiver and press a button.
The program should print out for example the NEC -code and the raw data.
The NEC -code should look like this: "FF906F".
Now you can try sending the same code by using sendNEC() method:
the 38 above is wrong. The second parameter is the lenght in bits. The Nec function will always send 38khz. Correct way is:
Irsend.sendNEC(0xFF906FF, 32);
Because the code you are sending is a HEX code you need to put the "0x" before it.
Some devices use their own protocols such as Samsung, but you can get the raw data from them. To clean the raw data you get from the dump -demo, you need to erase the first number, then convert all negative numbers to positive and place commas between the numbers.
Here's an example:
Raw data: 4802, -620, 500, -420, 600, -440....
Sending:
unsigned int[68] power_ON ={620,500,420,600,440... ...};
Irsend.sendRaw(power_ON, 68, 38);
68 is the length of the unsigned integer.
Hey,
ReplyDeleteNice post..The IRRemote library is built for atmega 168/328..but not for atmega8.Is there a way i can tweak the library for it to work with atmega8.Or is there any other similar IR remote library i can use with arduino.Basically all i want to do is interface a TSOP1738 ( IR Receiver ) with an arduino and the library should give me different outputs for different buttons pressed on the remote so i can differentiate between the different buttons in the remote and accordingly perform certain actions.
Thanks..
This helped me a lot before I found the IRreceive library.
ReplyDeletehttp://www.ladyada.net/learn/sensors/ir.html
@ville valta
ReplyDeletethanks a lot..that links seems useful..checking it out..
Thank you very much for sharing. This got me where I needed to be on sending raw IR using the Arduino library you mentioned.
ReplyDeleteI'm very pleased to hear that! And thanks a lot for leaving a comment :)
ReplyDeletehello
Deletei want to control led with remote in arduino
i m using atmage8
plz send me program
hello
ReplyDeletei want to control led with remote in arduino
i m using atmage8
plz send me program
Hi I have the same query. To interface TSOP1738 with ATMega8.
DeletePlease help me if you got a solution.
Thanks.
Thank you ! i finaly got my samsung tv to work,,,, any chance you could help with DISh network? i have tried every examble possible i can find , it uses the 20.0 ir remote i have tried raw and no luck
ReplyDeleteThank you!!!! Ken Shirriff should have posed something this useful into his blog too!!
ReplyDeleteThanx. It has hepled :)
ReplyDeleteThanks to your application I am able to control my AC from the internet with an android application!
ReplyDeleteHere is the tutorial for those interested (its in spanish though)
http://techcontostones.blogspot.com/2013/04/arduino-android-como-controlar-un-aire.html
You said ""38" in the constructor means that you want to send it with 38khz carrier frequensy."
ReplyDeleteI think this is wrong. The sendNEC function is declared this way in IRRemote.h:
void sendNEC(unsigned long data, int nbits);
As you see that parameter (nbits) is the number of bits to send. I think this is the same number reported when you capture the code with the IRRecvDump example. As in this log:
FF30CF
Decoded NEC: FF30CF (32 bits)
Raw (68): -28998 9100 -4400 650 -500 600 -500 650 -450 650 -500 600 -550 600 -500 650 -450 650 -500 600 -1650 600 -1650 600 -1650 600 -1600 650 -1600 650 -1600 600 -1650 600 -1600 650 -500 600 -550 600 -1650 600 -1650 600 -500 600 -500 650 -500 600 -550 600 -1600 650 -1600 600 -500 650 -500 600 -1650 600 -1650 600 -1650 600 -1600 650
To send this command I had to use:
irsend.sendNEC(0xFF30CF, 32);
Hi, i'm planning to control my sharp air conditioner over my android. But the problem is I cant find the correct decoding mechanism (it's detected as unknown if i'm using IRdump). And i've tried to use your way (samsung). but still can't work.
ReplyDeleteany workaround for this? thanks
@Ville valta
ReplyDeletelaita mulle meiliä, tarviin vähän apua tähän liittyen
Thank you very much! I used the method you described to control a toy robot :D
ReplyDeleteUsing the IRremote library doesn't seem to work for the Arduino UNO rev. 3
ReplyDeleteError: uint8_t recvpi, " no rawlen"??
I've got dis interesting site for dis. Try it.
ReplyDeletehttp://vaaiibhav.me/how-to-send-ir-signal-with-arduino/