$crystal = 4000000 Config Portb = Output Config Rc5 = Pind.2 Config Pind.5 = Output Dim E As Integer Enable Interrupts Start0: Dim A As Byte Dim C As Byte Getrc5(a , C) 'If A = 0 Then C = C And &B10111111 Select Case C Case 1 : Goto Ahead Case 2 : Goto Back Case 4 : Goto Fwd25 Case 7 : Goto Bwd25 Case 5 : Goto Fwd50 Case 8 : Goto Bwd50 Case 6 : Goto Fwd100 Case 9 : Goto Bwd 100 End Select 'End If Goto Start0 Ahead: Set Portb.0 Waitms 200 Reset Portb.0 Set Portb.1 Waitms 200 Reset Portb.1 Set Portb.3 Waitms 200 Reset Portb.3 Set Portb.2 Waitms 200 Reset Portb.2 Goto Start0 Back: Set Portb.2 Waitms 200 Reset Portb.2 Set Portb.3 Waitms 200 Reset Portb.3 Set Portb.1 Waitms 200 Reset Portb.1 Set Portb.0 Waitms 200 Reset Portb.0 Goto Start0 Fwd25: For E = 1 To 25 Step 1 Set Portb.0 Waitms 50 Reset Portb.0 Set Portb.1 Waitms 50 Reset Portb.1 Set Portb.3 Waitms 50 Reset Portb.3 Set Portb.2 Waitms 50 Reset Portb.2 Next E Goto Start0 Fwd50: For E = 1 To 50 Step 1 Set Portb.0 Waitms 20 Reset Portb.0 Set Portb.1 Waitms 20 Reset Portb.1 Set Portb.3 Waitms 20 Reset Portb.3 Set Portb.2 Waitms 20 Reset Portb.2 Next E Goto Start0 Fwd100: For E = 1 To 100 Step 1 Set Portb.0 Waitms 2 Reset Portb.0 Set Portb.1 Waitms 2 Reset Portb.1 Set Portb.3 Waitms 2 Reset Portb.3 Set Portb.2 Waitms 2 Reset Portb.2 Next E Goto Start0 Bwd25: For E = 1 To 25 Step 1 Set Portb.2 Waitms 200 Reset Portb.2 Set Portb.3 Waitms 200 Reset Portb.3 Set Portb.1 Waitms 200 Reset Portb.1 Set Portb.0 Waitms 200 Reset Portb.0 Next E Goto Start0 Bwd50: For E = 1 To 50 Step 1 Set Portb.2 Waitms 20 Reset Portb.2 .............