$regfile = "m32def.dat" $crystal = 8000000 Config Debounce = 35 Dim Z As Long Dim Zeitverstrichen As Long Dim G As Byte Dim M As Byte Dim N As Byte Dim Fehler As Byte Do Debounce Pind.0 , 1 , 5gramm_in , Sub Debounce Pind.1 , 1 , 5gramm_out , Sub Debounce Pind.2 , 1 , 10gramm_in , Sub Debounce Pind.3 , 1 , 10gramm_out , Sub If M = 1 Then Gosub Zeitlimit If M = 2 Then Gosub Zeitlimit If N = 1 Then Gosub Zeitueberschritten Loop 5gramm_in: G = G + 5 Portb.0 = 1 Z = 0 M = 1 Return 10gramm_in: G = G + 10 Portb.1 = 1 Z = 0 M = 2 Return 5gramm_out: G = G - 5 If G = 0 Then Portb.0 = 0 M = 0 End If Return 10gramm_out: G = G - 10 If G = 0 Then Portb.1 = 0 M = 0 End If Return Zeitlimit: Incr Z If Z > 10000 Then N = 1 Return Zeitueberschritten: If M = 1 Then Fehler = 1 M = 0 N = 0 End If If M = 2 Then M = 1 Portb.1 = 0 Portb.0 = 1 End If Return