ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

InfraRed (IR) Communication - How It Works

Updated on September 24, 2012
Oscilloscope Signals from IR Transmitter Circuit
Oscilloscope Signals from IR Transmitter Circuit
Nikola Tesla's Wardenclyffe Tower
Nikola Tesla's Wardenclyffe Tower

These days everything is wireless – radios, telephones, computers, and even your printer!

Did you know that the concept is actually over one hundred years old? Back in 1901, discoverer Nikola Tesla began construction of the Wardenclyffe Tower in Long Island, New York. It was intended to send and receive trans-Atlantic wireless telephony and even transmit electrical power wirelessly; however, due to financial problems, it was never completed. Today, wireless communication is everywhere, and wireless power transmission is currently being developed. For the electronics enthusiast, there are basically two forms of wireless communication: radio and infrared signals. Technologies such as Wi-Fi and Bluetooth are forms of radio communication. Your TV remote control works by sending infrared signals to your television, which receives those signals and processes them to change the channel, volume, etc. The downside of IR (infrared) is that it requires line-of-sight for transmission / reception. For most of your electronics and robotics projects, it is a cheap and easy way to free yourself of those pesky wires!

My Infrared Transmitter / Receiver Project

Sony InfraRed Communication (SIRC) Protocol

Some months back, I was looking for information on IR communication when I stumbled across Nigel Goodwin's PIC tutorial website. This project uses SIRC, a communication protocol developed by Sony for control of their TVs, DVD players, etc; therefore, you can use a Sony remote control (transmitter) to send signals to your receiver circuit if you so choose.

SIRC uses a pulse width system with a start bit of 2.4 ms duration, followed by 12 data bits, where a '0' is 0.6 ms wide, and a '1' is 1.2 ms wide. The bits are separated by 0.6 ms gaps. The data consists of a 7-bit command code followed by a 5-bit device code, where a command is Channel Up / Down or Volume Up / Down; and a device is a TV, DVD player, etc. By transmitting different device codes, the same remote control can be used to control different devices – depending upon to which device code a particular device's receiver circuit is programmed to respond.

The table below (Table 1) shows the data format. After the start bit, the command code is sent, least significant bit first (D0). Then the device code is sent, again least significant bit first (C0). The entire series is sent repeatedly while the button is pressed, every 45 ms. In order to decode the transmission, we need to measure the width of the incoming pulses. First, we look for the long 'start' pulse and then measure the next 12 pulses to determine if they are 0's or 1's. After measuring a pulse, it is tested to see if it is valid. This routine returns four possible results: start, zero, one, or error. The routine loops until a valid start pulse is detected and then reads the next 12 pulses. If any of those twelve pulses is anything other than a zero or a one, the program goes back and waits for another start pulse. For this project, we will use the command codes for Channel Up, Channel Down, Volume Up, and Volume Down. In decimal numbers, these are 16, 17, 18, and 19, respectively; however, in binary (as the program uses), they are 0000 100, 1000 100, 0100 100, and 1100 100, respectively. Note that the preceding binary numbers are backwards with the LSB first (opposite of conventional notation), shown as the receiving circuit will see them, D0 – D6.

Table 1
Table 1
Table 2
Table 2

The table to the right (Table 2) shows the device identifications. The five bits of the device code (C0 – C4) allow the possibility of up to 32 different device ID's (2^5 = 32).

Figure 1
Figure 1


For this project, we will be using two electronic circuits, one as a transmitter and one as a receiver. Each circuit uses a Microchip PIC16F684 microprocessor, which can be bought directly from Microchip or from eBay for less than a dollar per chip! The component count is low; however, there are a few uncommon parts that you might have to order. Again, I prefer to purchase small quantities of parts from eBay, as they are inexpensive and usually have free shipping. For those of you new to PIC chips, the ICP01 USB-to-TTL programmer can be purchased from for less than $20. (Figure 1)

Infrared Receiver Circuit w/ LCD Display and Servo Motor
Infrared Receiver Circuit w/ LCD Display and Servo Motor

Infrared Receiver Circuit

Simply Assemble the InfraRed receiver circuit on a solderless breadboard as shown in the IR-RX link below. Be sure to connect all of your grounds, or the circuit will not work! I have included connections for ISCP (In-Circuit Serial Programming) which connects to your PIC programmer via a 5-pin header. (If you order the iCP02, which comes with a sixth pin for +3.3VDC, ignore the last pin. The programmer's ribbon cable has a red stripe down one side to indicate the MCLR connection.) In this example circuit, Pin 2 on the PIC chip is used as the output pin. Connect Pin 2 to the device you want to control with your IR remote control. There are different PIC Assembly code programs for the receiver circuit ready for download at the links below. DIGITAL_IR_RX.asm can be used to send a pulse-width modulated output signal to control servos or speakers (musical tones). The code can be easily modified to send output signals to pins 5 - 10 (PORTC). After you modify your code (if you choose to do so), you will need to compile the .asm files into .hex files for download to your PIC chip.

Homemade IR Transmitter (Remote Control)
Homemade IR Transmitter (Remote Control)

Infrared Transmitter Circuit

Next, assemble the infrared transmitter circuit on another solderless breadboard as shown in the IR-TX link below. Again, be sure to connect all of your grounds! Connect your PIC programmer and download the IR_TX.hex file to your PIC chip via the ICSP pins. This circuit uses four momentary push button inputs with 10kΩ pull-up resistors for your Channel Up, Channel Down, Volume Up, and Volume Down commands. The function of these four buttons can be changed in the infrared receiver code.

It is worth noting that 4.7Ω resistors are uncommon and probably have to be ordered online. Make sure that your 4.7Ω resistor has a 3 watt (or greater) power rating! Here's why:

V/R = I (5Vsupply - 1.7VIR_LED) / 4.7Ω = 702 mA

I2R = P (0.702A) * (0.702A) * 4.7Ω = 2.3 Watts

3 Watts > 2.3 Watts

You might be wondering why a BC337 NPN transistor is necessary, rather than the more common 2N3904 NPN transistor. The 3904 is only rated for 200 mA collector current, where the BC337 is rated for 800 mA collector current (perfect for our 702 mA). The more current, the more power; the more power, the greater the transmission range of our IR transmitter circuit.

As a side note, if you do not have an IR LED, I found that a green (visible light) LED works just as well.

If you are already familiar with PIC programming, you may skip the following Software section.


In order to modify the PIC Assembly (.asm) code linked below, you will need a plain text editor such as Microsoft Notepad. Be sure to save your files with the .asm file extension, NOT .txt!

There are many PIC Assembly language compilers out there for free on the internet. Microchip offers free download of their MPLAB IDE (integrated development environment) at I use a DOS-based compiler called GPASM (general purpose assembler) available for free download at First, create a new Microchip folder inside of your Program Files folder. Then download the GPUTILS package to this file directory:

C:\Program Files\Microchip\

When you download the .asm files linked below, save them to this directory:

C:\Program Files\Microchip\gputils\bin\_______.asm

Next, press the START button at the bottom left corner of your computer screen, click the RUN button, and type CMD to bring up a window with the DOS prompt. Then type cd\ to get to your root directory C:\. Type this:

cd\Program Files\Microchip\gputils\bin

Now type gpasm _______.asm and press ENTER. For example, it should look like this:

C:\Program Files\Microchip\gputils\bin>gpasm Digital_IR_RX.asm

If you press ENTER and another command prompt pops up on the next line (and nothing else), then you have successfully compiled your PIC Assembly (.asm) language program and converted it to a .hex file. Otherwise, your code has errors. Now close the window with the DOS prompt.

Open your C:\Program Files\Microchip\gputils\bin folder, and you should now see a .hex file with the same filename as the .asm file. For example, Digital_IR_RX.hex.

You are now ready to download your .hex file to your PIC chip. For this, you will need to download the free PICkit2 v2.61 software from Microchip at the following web address:

Warning: disconnect any external power sources (i.e. 9 volt battery) from your solderless breadboard before going any further! If you connect your USB programmer to your circuit while a 9V battery is also connected, you could backfeed and fry your programmer and/or your USB port.

Go ahead and connect your USB-to-TTL PIC programmer to your computer's USB port and to the ICSP header on your solderless breadboard. After installing the downloaded software to your desktop, open it by double-clicking on the icon. You should see a small window on the PICkit2 software that says, "PICkit 2 Connected. ID = iCP01-V1.0". If it says, "PICkit 2 not found.", then make sure that your programmer is connected to both your computer and circuit. Then click Tools at the top of the PICkit2 window, which will drop down a menu where you will click on Check Communication. That should fix your connection problem. Now click File > Import Hex and select your .hex file from your C:\Program Files\Microchip\gputils\bin folder and click Okay. Finally, click Write on the main window of the PICkit2 software, which will download your .hex file to your PIC chip. The program will begin running immediately and automatically in your PIC chip, as your circuit is powered by the USB ports's +5VDC supply voltage. Give your USB programmer about 5 to 10 seconds to complete the download of the .hex file before disconnecting your programmer from the ICSP port on your circuit, though it generally only takes two or three seconds. Now that your USB programmer is disconnected, you may connect the 9V battery to your circuit. Follow this process for both the transmitter and receiver circuits, and you'll be ready to transmit and receive infrared signal!

Congratulations, you're wireless!


    0 of 8192 characters used
    Post Comment
    • profile image

      Aaron Ward 

      5 years ago

      Thanks, John! ...I have a video on YouTube too that you might enjoy.

    • profile image

      John Jennings 

      5 years ago

      Just found this, it's a really good article. Thanks

    • profile image

      Aaron Ward 

      5 years ago

      E-mail me at, and I'll send you the files.

    • profile image


      5 years ago

      dear SamuelAaronWard

      how are you

      I couldn't find the code or see it

      please can you help me .


    • profile image


      6 years ago

      Thanks Aoron.

    • SamuelAaronWard profile imageAUTHOR

      Samuel Aaron Ward 

      6 years ago from Kenova, West Virginia, USA

      Yes. I will e-mail them to you.

    • profile image


      6 years ago

      Hey Aoron,My Email ID Is .I Couldn't Solve This Problem.Can U Pls Send Me The Codes(Tx & Rx) In Ms Word Or Pdf Format To My Mail.It's Very Important To Try Ur (This) Project For,I m really very Interested,So ......Pls....

    • SamuelAaronWard profile imageAUTHOR

      Samuel Aaron Ward 

      6 years ago from Kenova, West Virginia, USA

      E-mail me at, and I will send you the code.

    • profile image


      6 years ago

      That Is Very Nice.but I Have A problem..I Was Unable To See The Program Code.It's Prblem By Google Dock In My Country,Pls Give Me A Suggetion How Can I Get It...PLs Pls I M Very Interested

    • NiaG profile image


      6 years ago from Louisville, KY

      Wow! I had no idea. Thank you Aaron for bringing this to light. Voted Up! Welcome to HubPages. Looks like you're off to a good start.


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
    ClickscoThis is a data management platform studying reader behavior (Privacy Policy)