RC5 Protocol Remote Control Decoder Using Pic

RC5 Protocol Remote Control Decoder

This project shows how to decode IR remote controls which uses Philips RC5 protocol with microchip PIC16F84A microcontroller.
You can find details about RC5 on Wikipedia
Related topics:
Philips RC5 & LG TV Remote Control Decoder
IR Remote Control Based On PIC Microcontroller
The RC5  protocols can be divided into 4 parts:
1-start bit,
2-Toggle bit,
3-Address (5 bits),
4-Command (6 bits).

RC5 Protocol Remote Control Decoder

The code:

The code of this project is written using mikroc pro for pic compiler. The crystal used is 12MHz.

//PIC16F84A RC5 Protocol Remote control decoder MikroC code

//http://www.elecnote.blogspot.com
//electronnote@gmail.com
//Used crystal: 12MHz
//Use at your own risk

 // LCD module connections
sbit LCD_RS at RB6_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB1_bit;
sbit LCD_RS_Direction at TRISB6_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB1_bit;
// End LCD module connections

unsigned short ir_read, j, toggle, address=0, command=0;
unsigned char  *text, mytext[3];
 void Interrupt(){               //External interrupt occured
 //Check if the received signal is RC5 protocol
  delay_us(370);
  if(PORTB.F0==0){
  delay_us(889);
  if(PORTB.F0==1){
  delay_us(889);
  if(PORTB.F0==0){
  delay_us(1778); ir_read = 1;
  INTCON  = 0;                //Disabe the external interrupt
 }}}
 INTF_bit = 0;                //Clear Interrupt flag
}
   //Display the results on 1602 LCD
  void display_results (){
   Lcd_Cmd(_LCD_CLEAR);            //Clear LCD
   text = "Tgl:" ;
   Lcd_Out(1, 2, text);
   text = "Ads:" ;
   Lcd_Out(1, 10, text);
   text = "Cmd:" ;
   Lcd_Out(2, 6, text);
   ByteToStr(toggle, mytext);   Lcd_Out(1, 6, Ltrim(mytext));
   ByteToStr(address, mytext);  Lcd_Out(1, 14, Ltrim(mytext));
   ByteToStr(command, mytext);  Lcd_Out(2, 10, Ltrim(mytext));  }

RC5 Protocol Remote Control Decoder Schematic

Read more: RC5 Protocol Remote Control Decoder

Leave a Comment

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