vinodstanur
Advanced Member level 3
- Joined
- Oct 31, 2009
- Messages
- 751
- Helped
- 114
- Reputation
- 234
- Reaction score
- 114
- Trophy points
- 1,333
- Location
- Kerala (INDIA)
- Activity points
- 7,054
Below is my RC-5 decoding code for PIC16F84A.
But you can use it in any PIC by small modifications...
You can control it using a PHILIPS TV remote (RC5 protocol). But i think almost all philips TV remote follows this protocol.
You can use any IR remote working with RC-5 protocol because the program only detects the 6 command bits and all others are ignored.
I didn't included a PWM in this because at the time when i coded this, my aim was just to decode RC5 signal. More over, PIC16F84A doesn't have PWM module, but a software PWM is possible...
Now, you can include more devices by understanding the 6bit command for each key in a Philips TV remote, so that you can select any key for PWM. You can learn more about Philips RC5 protocol from below link.
SB-Projects: IR Remote Control, Philips RC-5 Protocol
---------- Post added at 10:27 ---------- Previous post was at 10:09 ----------
TSOP output is to be connected to RB0.
---------- Post added at 10:33 ---------- Previous post was at 10:27 ----------
---------- Post added at 10:46 ---------- Previous post was at 10:33 ----------
PHP:
/*TARGET MICROCONTROLLER -PIC16F84A*/
/*COMPILER - High Tech C */
#include <pic.h>
#define _XTAL_FREQ 4e6
#define us __delay_us
#define ms __delay_ms
unsigned char buf,flag;
__CONFIG(0x3FFA);
void interrupt RC5() //RC5 decoding inside ISR
{
INTF=0;
if(RB0==0)
{
us(100);
if(RB0==0)
{
us(100);
if(RB0==0)
{
us(889);
if(RB0==1)
{
us(889);
if(RB0==0)
{
ms(10.632);
buf=0;
for(int a=0;a<6;a++)
{
buf<<=1;
if(RB0==1)
{
buf++;
}
ms(1.778);
}
buf&=0b00111111; /*SIX COMMAND BITS EXTRACTED*/
flag=1;
RA3=1;ms(30);RA3=0;
}
}
}
}
}
}
main()
{
__delay_ms(50);
__delay_ms(100);
__delay_ms(50);
PORTB=0;
PORTA=0;
TRISB=1; //To make RB0 as input
TRISA=0;
GIE=1; //Global interrupt enable
INTE=1; //RB0 interrupt enable
INTEDG=0; //Interrupt on High to Low transition
while(1)
{
flag=0;
if(buf==0){RB1=~RB1;}
else if(buf==1){RB2=~RB2;}
else if(buf==2){RB3=~RB3;}
else if(buf==3){RB4=~RB4;}
else if(buf==4){RB5=~RB5;}
else if(buf==5){RB6=~RB6;}
else if(buf==6){RB7=~RB7;}
else if(buf==7){RA0=~RA0;}
else if(buf==8){RA1=~RA1;}
else if(buf==9){RA2=~RA2;}
flag=0;
while(flag==0);
}
}
You can control it using a PHILIPS TV remote (RC5 protocol). But i think almost all philips TV remote follows this protocol.
You can use any IR remote working with RC-5 protocol because the program only detects the 6 command bits and all others are ignored.
I didn't included a PWM in this because at the time when i coded this, my aim was just to decode RC5 signal. More over, PIC16F84A doesn't have PWM module, but a software PWM is possible...
Now, you can include more devices by understanding the 6bit command for each key in a Philips TV remote, so that you can select any key for PWM. You can learn more about Philips RC5 protocol from below link.
SB-Projects: IR Remote Control, Philips RC-5 Protocol
---------- Post added at 10:27 ---------- Previous post was at 10:09 ----------
TSOP output is to be connected to RB0.
---------- Post added at 10:33 ---------- Previous post was at 10:27 ----------
---------- Post added at 10:46 ---------- Previous post was at 10:33 ----------
Last edited: