IR Protocol Decoding and Transmiting through Arduino

You can Translate this page into various languages.

In this blog, I will described various IR protocols adopted by different companies and will go in detail about 2 protocols. One is the most commonly used NEC protocol and another is the Samsung protocol. Why??? Because I have Samsung TV which uses its own protocol and a GTPL setup box, which uses NEC protocol as simple as that.

Different Companies uses their own protocols for eg. we have protocols like Samsung, LG, RC5/RC6 by Philips,and the most commonly used protocol NEC protocol.

Lets discuss the two protocols in detail.

SAMSUNG Protocol

Samsung protocol goes in sequence like a start bit,8 bit address,8 bit address,8 bit data and inverse of 8 bit data. In total there are 32 bits after start bit containing address and data.Start bit of this goes like HIGH for 4.5 ms and LOW for 4.5 ms. Followed by this start bit, address and data bits are transmitted. Frequency of transmission is around 38 kHz. To be precise it is 37.9 kHz. Level HIGH and level LOW is decided based on the duration on the low level of the signal. Logic 1 and 0 is decoded like this:


IR signal of samsung protocol will look something like this, and its sequence goes like
start bit – Address – Address – Data – Inverse Data – stop bit
start bit- 11100000 11100000 00100000 11011111-stop bit

This signal contains address – 11100000 data – 00100000.

NEC Protocol

NEC protocol is most commonly used for IR communication. Its frequency of transmission is around 38kHz. The difference in samsung protocol and NEC protocol can be easily identified by the start bit. Samsung has 4.5 ms mark and 4.5 ms space while NEC protocol have a start bit of 9 ms mark and 4.5 ms space.


Another difference between samsung protocol and NEC protocol is that NEC protocol contains Address and inverse of Address after that while samsung protocol repeats the address twice. Logic 1 and 0 of this protocol is same as that of samsung protocol.

Decoding and Transmitting Through Arduino

Decoding this signal using arduino is very simple. We will use pulseIn() function to read the duration of the pulse and accordingly decide weather the received bit is high or low.
Things Required;
1. Arduino Board
2. TSOP IR reciever
TSOP IR reciever will give digital output of the IR data received on 38 kHz frequency. By default, it will give digital 1.
Note: This receiver will give the inverse output. i.e. If IR signal transmitted is 0, than TSOP reciever will give output 1.


First of all we will wait for the start bit of the signal. After that we will turn ON the led for indicating that IR signal is received.(This is the example of decoding a NEC IR signal).
2STEP 2:
Than we will check that whether the received data is logic 1 or 0 and we will store that 32 bit data in a boolean array.


Than we will separate address and data from this array. Now as we know that in NEC protocol the first 8 bits are the address and 17th to 24th bit are the data. Hence we will sort it accordingly.


Thats it. We have decoded the NEC protocol. Now lets see how to transmit it via IR LED.



First of all we will make a array of 32 bit and store the address in first 8 bits and the inverse of the address in another 8 bits. I am fetching the address value in integer from EEPROM.

STEP 2:Than we will store the data and inverse of the data in the remaining 16 bits of the array.



Than we will transmit this 32 bit data along with start bit and stop bit.Start bit of NEC protocol is HIGH for 9 ms and LOW for 4.5 ms. Here burst is the function which will send the HIGH signal at 38kHz frequency.

Burst is the function which will send pulses at 38 kHz frequency. Value of the burst signal may vary because of the time delay of the instructions. So I have tried by different divisions, and finally the transmitter was working when I divided the HIGH time delay by 38 for which actual dividend by calculation comes out to be 26 (9 us+17 us).
That’s it. You are done with the decoding and transmission. You can even store the codes of the remote sequentially in the EEPROM and than transmit the code by fetching the data from EEPROM.
The pics in this blog are example of NEC protocol. I have attached link of a code for decoding and transmission of code of Samsung protocol.Further I am trying to make a self learning universal remote control which can simply copy the code into the memory and can be able to transmit the same signal. So that the issue of different protocols will be nullified.If any one have any idea regarding learning remote, do mail me.

Arduino Files:

explore | learn | share

Leave a Reply

Your email address will not be published. Required fields are marked *