Shopping Cart
Your Cart is Empty
There was an error with PayPalClick here to try again
CelebrateThank you for your business!You should be receiving an order confirmation from Paypal shortly.Exit Shopping Cart

Lennard Electronics Ltd

Make your own RC5 Remote Control

The RC5 remote control protocol is very simple to implement.

This page shows you how to make an Infrared Remote Control using a simple circuit based around an 8051 microcontroller, and code written in C.

How the RC5 protocol works

The Philips RC5 remote control protocol works as follows:

Send two start bits, then a toggle bit, a 5 bit device address, then a 6 bit command.

The toggle bit changes to indicate a button press and button release.

The address is unique to the type of device you are controlling (TV, Video, DVD, etc.)

As the Dual CD Player I am talking to can learn the commands from any RC5 remote control, I could make up my own command set. This can be changed in the C code for the 8051 microcontroller, but at the moment the address I am using is 0x0F, and my commands (which relate to button presses) are 0x00 to 0x1C.

So, for example, when I press play on my remote, the following bit stream is sent, MSB first:

0x01,0x01,0x01,0x0F,0x0A and I immediately follow it with 0x01,0x01,0x00,0x0F,0x0A (that is, I don’t wait for the user to release the button).

The only different between the two streams is the toggle bit.


Each bit takes 1.778mS to send. So that’s about 25mS for a button down code and another 25mS for a button up code.

Each bit is encoded using Manchester encoding. A logic 0 is represented by the data line going high for the first 889uS then low for the second 889uS, a logic 1 is represented by the data line going low for the first 889uS then high for the second 889uS. The high part of the signal is known as the "Mark", the low part of the signal is known as the "Space". 

Figure 1 shows the data stream for the play button being pressed.

Figure 1

The IR LEDs are flashed at 38kHz to represent a Mark. Figure 2 shows the modulated data stream for the play button being pressed.

Figure 2

Circuit Diagram Download the Eagle CAD schematic and PCB to make your own PCB.

The circuit is made up of three basic blocks.

1). Switch array, arranged in 4 columns by 7 rows.

2). 8051 based microcontroller.

3). IR LED drive.

The 8051 continuously scans each button by applying a logic 1 to each column one after the other, and then reading the row of switches on that column.

Depending on which switch is pressed, the value read in on port 1 will be either 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, or 0x80.

For example, if column 1 has a logic 1 on it, then the input to P1 will be the switches in that column. If the switch connected to Port 1^ 2 is pressed, then a logic 1 will be presented to Port 1^ 2. Reading Port 1 while column 1 is high will result in a value of 0x02, and as we know column 1 is high we can tell that the Play button has been pressed.

Now that we know which button has been pressed, we can now send the associated code via the LEDs.

The current limiting resistor for the LEDs is only 2.7 ohms, but as the LEDs are only on for a very short burst, this will ensure a nice bright IR light while still keeping the power dissipation within limits of the LEDs.

The MOSFET can be replaced with a BC549, it works just as well. The IR LED's were sourced from Jaycar Electronics, cat # ZD1945.

The circuit diagram doesn't show a power switch, but I'd add one...

Here's what my PCB looks like. The switches and 8051 MCU are mounted on the bottom layer, power supply on the top layer.

Of course, you can design your own layout if you want, using the Eagle files from the links above.

Here is a finished working prototype in a 3D Printed case. The keypad was made with adhesive backed paper, covered with Duraseal.

The Code

The code for the hand held remote has been written in C using SDCC, and the Silicon Labs IDE.

Here is the code. The .h file is here.


This is a prototype design. It was developed on a Silicon Labs C8051F005 development board and proves the concept works.

Ideally, a single 1.5V battery would be better as a supply, with no need for a power switch.

Silicon Labs do produce a low power 8051, with on board power management, and this would be an ideal chip to use for a more compact and battery friendly version.