$regfile = "m8def.dat" $crystal = 8000000 $baud = 9600 Config Portd = Output Config Portb = Output Config Portc = Output Portb = &B11110000 Portc = &B01111000 Portd = 0 Dim Speednow As String * 1 Dim Directionnow As String * 1 Dim Speedfuture As String * 1 Dim Directionfuture As String * 1 Dim Check As String * 1 Dim J As String * 1 Dim I As Byte Config Pind.2 = Input On Int0 Button Enable Int0 Enable Interrupts Portd.3 = 1 Main: Do For I = 1 To 4 Check = Waitkey() If Check = "1" Then Speednow = Waitkey() If Check = "2" Then Directionnow = Waitkey() If Check = "3" Then Speedfuture = Waitkey() If Check = "4" Then Directionfuture = Waitkey() Next Portd.7 = 1 Waitms 500 Portd.7 = 0 J = Speednow Gosub Dispspeed J = Directionnow Gosub Dispdir Loop End Button: Portd.3 = 0 Portd.4 = 1 J = Speedfuture Gosub Dispspeed J = Directionfuture Gosub Dispdir Wait 5 Portd.4 = 0 Portd.3 = 1 J = Speednow Gosub Dispspeed J = Directionnow Gosub Dispdir Return Dispspeed: Portc = &B01111000 If J = "1" Then Portc.6 = 0 Portc.0 = 1 End If If J = "2" Then Portc.6 = 0 Portc.1 = 1 End If If J = "3" Then Portc.6 = 0 Portc.2 = 1 End If If J = "4" Then Portc.5 = 0 Portc.0 = 1 End If If J = "5" Then Portc.5 = 0 Portc.1 = 1 End If If J = "6" Then Portc.5 = 0 Portc.2 = 1 End If If J = "7" Then Portc.4 = 0 Portc.0 = 1 End If If J = "8" Then Portc.4 = 0 Portc.1 = 1 End If If J = "9" Then Portc.4 = 0 Portc.2 = 1 End If If J = "a" Then Portc.3 = 0 Portc.0 = 1 End If If J = "b" Then Portc.3 = 0 Portc.1 = 1 End If If J = "c" Then Portc.3 = 0 Portc.2 = 1 End If Return Dispdir: Portb = &B11110000 If J = "1" Then Portb.4 = 0 Portb.3 = 1 End If If J = "2" Then Portb.4 = 0 Portb.2 = 1 End If If J = "3" Then Portb.4 = 0 Portb.1 = 1 End If If J = "4" Then Portb.4 = 0 Portb.0 = 1 End If If J = "5" Then Portb.5 = 0 Portb.3 = 1 End If If J = "6" Then Portb.5 = 0 Portb.2 = 1 End If If J = "7" Then Portb.5 = 0 Portb.1 = 1 End If If J = "8" Then Portb.5 = 0 Portb.0 = 1 End If If J = "9" Then Portb.6 = 0 Portb.3 = 1 End If If J = "a" Then Portb.6 = 0 Portb.2 = 1 End If If J = "b" Then Portb.6 = 0 Portb.1 = 1 End If If J = "c" Then Portb.6 = 0 Portb.0 = 1 End If If J = "d" Then Portb.7 = 0 Portb.3 = 1 End If If J = "e" Then Portb.7 = 0 Portb.2 = 1 End If If J = "f" Then Portb.7 = 0 Portb.1 = 1 End If If J = "g" Then Portb.7 = 0 Portb.0 = 1 End If Return