'Bascom Pulszähler
$regfile = "m88def.dat"
$crystal = 16000000
$baud = 19200

Config Timer0 = Counter , Edge = Falling
Timer0 = 0

Zaehleingang Alias Pind.4
Config Zaehleingang = Input
Portd.4 = 1

S2 Alias Pind.2
Config S2 = Input
Portd.2 = 1

Dim Zaehler As Long
Dim Zaehler_last As Long

Enable Timer0
Enable Interrupts


Do

  Zaehler = Timer0

  If Zaehler <> Zaehler_last Then
     Print Zaehler
     Zaehler_last = Zaehler
  End If

  If S2 = 0 Then Timer0 = 0

  Wait 5

Loop
End