$regfile = "m8def.dat"
$crystal = 3686400
$baud = 19200

$hwstack = 32                                               ' default use 32 for the hardware stack
$swstack = 10                                               ' default use 10 for the SW stack
$framesize = 12                                             ' default use 40 for the frame space

Dim Rc5_address As Byte
Dim Rc5_command As Byte
Dim Rc5_bit_nr As Byte
Dim Toggle_bit As Boolean

Config Portb = Output
Config Pinc.0 = Input                                       'Input Wählen

                                                'Pullup Widerstand auf Hi

Declare Sub Logic_0
Declare Sub Logic_1
Declare Sub Startbit
Declare Sub Stopbit
Declare Sub Agc

Portc.0 = 1
Portb.0 = 1

Do

If Pinc.0 = 0 Then                                          'Vol+

Agc
Startbit
Logic_1
Logic_1
Logic_1
Logic_0

Logic_0
Logic_0
Logic_1

Logic_0
Logic_0
Logic_1
Logic_0

Logic_0
Logic_0
Logic_0

Stopbit

Waitus 32800
Startbit
Logic_1
Logic_1
Logic_1
Logic_0

Logic_0
Logic_0
Logic_1

Logic_0
Logic_0
Logic_1
Logic_0

Logic_0
Logic_0
Logic_0

Stopbit

Waitus 32800
Startbit
Logic_1
Logic_1
Logic_1
Logic_0

Logic_0
Logic_0
Logic_1

Logic_0
Logic_0
Logic_1
Logic_0

Logic_0
Logic_0
Logic_0

Stopbit

Waitms 200
End If

Loop

End

'-------------------------------------------------------------------------------

Sub Agc
  Portb.0 = 0                                          
  Waitus 8500
  Portb.0 = 1
  Waitus 4000
End Sub

Sub Startbit
  Portb.0 = 0                                               
  Waitus 600
  Portb.0 = 1
  Waitus 1550
End Sub

Sub Stopbit
  Portb.0 = 0                                               
  Waitus 600
  Portb.0 = 1
  Waitus 1550
  Portb.0 = 0                                               
  Waitus 600
  Portb.0 = 1                                               
End Sub

Sub Logic_0
  Portb.0 = 0                                               ' Bitmuster Lo
  Waitus 600
  Portb.0 = 1
  Waitus 550
End Sub

Sub Logic_1                                                 ' Bitmuster Hi
  Portb.0 = 0
  Waitus 600
  Portb.0 = 1
  Waitus 1550
End Sub