IR remote control system based on PIC microcontroller – CCS C compiler

5-Channel IR RC5 remote control encoder/decoder using PIC18F4550 microcontroller

This topic shows how to build an infrared remote control transmitter and receiver using PIC18F4550 microcontroller and CCS PIC C compiler.
The IR system has two circuits: transmitter circuit and receiver circuit. Both circuits have the same microcontroller type which is PIC18F4550.
This system uses RC5 protocol from Philips. The following link shows how to decode RC5 IR remote control:
RC-5 remote control decoder with PIC18F4550 and CCS C

The RC5 protocol message is 14-bit data length which are 2 start bits, 1 toggle bit, 5 address bits and 6 command bits as shown in the following figure. The most important are the address and command bits.
RC-5 message code

The IR signal needs a carrier frequency and the carrier frequency of the RC5 protocol is 36KHz with a duty cycle of 25% to 33%.
The following figure shows a complete RC5 code with a simple example:
RC-5 message code details

IR RC-5 remote control transmitter circuit (RC-5 Encoder):
The following image shows the transmitter circuit schematic of the IR system.
There are five push buttons in the circuit, each push button sends a different IR code via an IR transmitter.
PIC18F4550 internal oscillator is used (8MHz) and MCLR is disabled.
PIC18F4550 IR remote control transmitter circuit
The PIC18F4550 MCU needs 5V supply on its VDD and VSS pins. Its internal oscillator is used and MCLR pin function is disabled.

IR RC5 remote control transmitter circuit using PIC18F4550 CCS C code: 
To get a carrier frequency of 36KHz, PIC18F4550 PWM1 module is used with 25% duty cycle.
Logic 0 code with carrier frequency:

pwm_on();
delay_us(889);
pwm_off();
delay_us(889);

And logic 1 code with carrier frequency:
pwm_off();
delay_us(889);
pwm_on();
delay_us(889);

In the circuit there are five pushbuttons: B1, B2, B3, B4 and B5, they send the following address and command codes:
B1: address = 0 and command = 0,
B2: address = 0 and command = 1,
B3: address = 0 and command = 2,
B4: address = 0 and command = 3,
B5: address = 0 and command = 4.
The two start bits are always 1’s and the toggle bit might be 1 or 0.
The following C code is the full code for this circuit and it was tested with CCS PIC C compiler version 5.0.51.

IR RC-5 remote control transmitter circuit (RC-5 Decoder):
The RC5 IR receiver circuit schematic (RC5 decode) is shown below:
PIC18F4550 IR remote control receiver circuit
PIC18F4550 internal oscillator is used (8MHz) and MCLR is disabled. It needs +5V on its VDD – VSS pins.
In the receiver circuit there are 5 LEDs, each LED is controlled by one pushbutton on the transmitter circuit. The IR receiver receives IR signals transmitted from the IR transmitter on the transmitter circuit.

IR RC5 remote control receiver circuit using PIC18F4550 CCS C code:
The microcontroller waits until an IR signal is received (RB0 pin goes from high to low). After an IR signal is received the microcontroller checks if the received signal uses RC5 protocol, if so the microcontroller starts decoding the RC5 signal and the most important are the address bits and the command bits.
If address = 0 and command = 0: toggle LED1
If address = 0 and command = 1: toggle LED2
If address = 0 and command = 2: toggle LED3
If address = 0 and command = 3: toggle LED4
If address = 0 and command = 4: toggle LED5

The following C code is the full code for the receiver microcontroller:

IR remote control system based on PIC microcontroller video: 
The following video shows a hardware circuits for the project.

1 thought on “IR remote control system based on PIC microcontroller – CCS C compiler”

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top