Code:
'include "ALLDIGITAL.pbp"
@ DEVICE pic16F877a, WDT_OFF ' Watchdog Timer
@ DEVICE pic16F877a, PWRT_OFF ' Power-On Timer
@ DEVICE pic16F877a, BOD_OFF ' Brown-Out Detect
 
@ DEVICE pic16F877a, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F877a, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F877a, PROTECT_OFF ' Program Code Protection
@ DEVICE pic16F877a, HS_OSC 
 
Define OSC 20 
 
Header var word
Body var word
i var byte
tmp var Byte
irButton var byte
irDevice var byte 
 
irIN var PortB.2 
SonyLED var PortB.5 
 
 
'TrisA = %00000100 
TrisB = %00000100 
 
Start:
LOW SONYLED 
IRBUTTON=255: IRDEVICE=255
 
 
Pulsin irin,0,header 
if header < 1000 or header > 1350 then goto Start
 
 
for i =0 to 11
pulsin irin,0,tmp 
if tmp >= 480 then
Body.0[i]=1 'Sony Logic 1 is 120
else
Body.0[i]=0 ' Sony Logic 0 is 60
endif
next
 
IRBUTTON = Body & %01111111 'Mask 7 bit 
IRDEVICE = (Body >>7) & %00011111 'Mask 5 bit 
 
If IRDEVICE=255 then goto start
 
 
if IRBUTTON >=0 and IRBUTTON < 255 then
high Sonyled
pause 300
low Sonyled
endif
 
pause 100
goto start



the above code works....
but it is for all infrared buttons on the remote.i only want one button to do on/off of relay.if i replace this
Code:
 
if IRBUTTON >=0 and IRBUTTON < 255 then
by this

Code:
 
if IRBUTTON =16 then 'for channel up

it is not working .