'----------------------------------------------------------------------------
'                      RC5.BAS  (c) 1999 MCS Electronics
'  connect SFH506-36 IR-receiver to PORT 3.2 (INT0)
'----------------------------------------------------------------------------
Dim New As Bit
Dim Command As Byte , Subaddress As Byte

Reset Tcon.0                                                  'triggered by rising edge
On Int0 Receiverc5
Enable Int0
Enable Interrupts
Do
  If New = 1 Then                                             'received new code
     Disable Int0
     Print Command ; "  " ; Subaddress
     New = 0                                                  'reset new bit
     Enable Int0
  End If
Loop



Receiverc5:                                                   'interrupt routine
  'the getrc5 routine uses 30 bytes ! of the stack for measuring
  'the interval between the bits
  Getrc5(Subaddress,command)
  New = 1                                                     'set flag
Return