Sorry for wrong post this is proton code
I did make code with ir decode for control on/off output
now ir decode work properly but we need to add input switch for control also.
Right now we used interrupt with RB0 for monitor IR modul active but don't work
I'm not clear once interrup rb0 found and goto "disable" and effected to pulsin disable also or not
Pls advise too , Below is may code
code{}
DEFINE LOADER_USED 1
Include "PROTON_4.INC"
'Enable Debug
Dim IR As Word
Dim pulses[33] As Byte
Dim BitMask As Word
Dim i As Byte 'loop index
Dim b As Byte 'byte index
Dim LeadIn As Word 'start pulse
dim sw1 as portb.1
OPTION_REG = %00000111
INTCON = %00100000
TRISB = %00000011
ON_INTERRUPT GoTo loop
Main:
If sw1=0 then
toggle portb.4
endif
GoTo Main
Output_drive:
'for i = 0 to 31
' HSEROUT ["B",dec pulses[i],13,10]
'next
HSerOut ["W ",Dec BitMask,13,10]
HSerOut ["Bot ",Dec BitMask.LowByte,13,10]
HSerOut ["Cmd ",Dec BitMask.HighByte,13,10]
'-- output control --------------
If BitMask.LowByte = 84 Then
If BitMask.HighByte = 41 Then
If PORTB.4 = 0 Then
PORTB.4 = 1
Else
PORTB.4 = 0
EndIf
EndIf
EndIf
BitMask =0 'clear
DelayMS 50
GoTo Active_INT
Disable
loop:
'toggle portb.6
PulsIn PORTB.0, 0, LeadIn
If LeadIn < 400 Then GoTo Active_INT '885
If LeadIn > 1045 Then GoTo Active_INT
For i = 0 To 31
PulsIn PORTB.0, 1, pulses[i]
Next
For i = 16 To 27
If pulses[i] > 40 Then
If pulses[i] < 300 Then
GoTo Active_INT
EndIf
EndIf
If pulses[i] > 99 Then
BitMask.0 = 1
BitMask = BitMask << 1
EndIf
BitMask.0 = 0
BitMask = BitMask << 1
Next
GoTo Output_drive
Active_INT:
Resume ' Return to main program
Enable ' Enable interrupts after the handler
End
Bookmarks