'********************************************* ' Scheiben wischer N° 4 '********************************************* $regfile = "2313def.dat" $crystal = 4000000 ' unkritisch $hwstack = 40 $swstack = 16 $framesize = 32 Declare Sub Rut_alt() '* Wechsel Declare Sub Rut_1() '* Langsam Declare Sub Rut_2() '* Schnell Declare Sub Rut_stop() '* Alles aus '*********************** ' Konstanten '*********************** Const Ein = 0 ' Einschalten auf 0 Const Aus = 1 ' Auschalten auf 1 Const Notset = 0 '******************************* ' Ausgänge Configuration '******************************* Motor1 Alias Portb.1 'Motor Ausgänge Config Portb.1 = Output Motor2 Alias Portb.2 Config Portb.2 = Output Led1 Alias Portb.0 ' LED für Alternance kontroll Config Portb.0 = Output '***************************** ' Eingänge Configuration '***************************** Schleife Alias Pind.4 ' Schleifer auf 0 Config Pind.4 = Input Portd.4 = 1 ' Pullup Alternance Alias Pind.0 ' Position 1 - Wechsel Config Pind.0 = Input Portd.0 = 1 'Pull Up Position1 Alias Pind.1 ' Position 2 - Langsam Config Pind.1 = Input Portd.1 = 1 ' Pull Up Position2 Alias Pind.2 ' Position 3 - Schnell Config Pind.2 = Input Portd.2 = 1 ' Pull Up '*********************************************** ' Start '*********************************************** Portb = &HFF ' Alle Port auschalten Do If Alternance = Ein Then '* Wechsel ein ? Gosub Rut_alt '* Nein, abarbeiten Elseif Position1 = Ein Then '* Position 1 ? Gosub Rut_1 '* Ja, gehe zu Rut_1 Elseif Position2 = Ein Then '* Position 2 ? Gosub Rut_2 '* Ja, gehe zu Rut_1 Else '* Schalter ist auf Positon 0 (Aus) Led1 = Aus Gosub Rut_stop '* Alles ausschalten End If Loop '*********************************** ' Sub '*********************************** '*********************************** ' Alternance '*********************************** Sub Rut_alt() Led1 = Ein ' * LED On While Alternance = Ein Motor1 = Ein ' * Langsam Ein Waitms 50 ' * Kurz warten While Schleife = Ein ' * Warten, bis Schleifer aus der EndPosition raus ist Waitms 50 ' * noch mal warten Wend While Schleife <> Ein '* Warten, bis Schleifer EndPosition erreicht Wend Motor1 = Aus Wait 1 ' * 1 sec warten Wend Gosub Rut_stop ' * Alles ausschalten End Sub '********************************** ' Sub Rut_1() Motor2 = Aus Motor1 = Ein Led1 = Aus Waitms 30 '* Prellen (Debounce) !! End Sub Sub Rut_2() Motor1 = Aus Motor2 = Ein Led1 = Aus Waitms 30 '* Prellen (Debounce) !! End Sub Sub Rut_stop() While Schleife <> Ein Wend Led1 = Aus Motor1 = Aus Motor2 = Aus End Sub