Hallo,

ich habe da mal ein kleines Programm mit LED's geschrieben und dabei incr benutzt.
Nur arbeitet das Programm nicht alles nacheinander ab, sondern abwechselnd, bin mir sicher, dass es an den < und > liegt

Hier mein Programm:

Code:
  $regfile = "m32def.dat"
 ' $framesize = 32
  '$swstack = 32
  '$hwstack = 32
  $crystal = 16000000
  $baud = 9600

'--------LED-----------
Config Porta = Output

'--------Taster--------
Config Pinb.0 = Input
Portb.0 = 1


Declare Sub Lauflicht
Declare Sub Allean
Declare Sub Nacheinander
Declare Sub Startrek

Dim Anzahl As Byte

Do

   If Pinb.0 = 1 Then

Incr Anzahl
If Anzahl < 25 Then Gosub Lauflicht
If Anzahl > 25 Then Gosub Allean
If Anzahl > 50 Then Gosub Nacheinander
If Anzahl < 50 Then Gosub Startrek
If Anzahl = 75 Then Anzahl = 0

End If

Loop


Sub Startrek
   Print "Star Trek"
   Porta.0 = 1
   Porta.6 = 1
   Waitms 150
   Porta.0 = 0
   Porta.6 = 0
   Porta.1 = 1
   Porta.5 = 1
   Waitms 150
   Porta.1 = 0
   Porta.5 = 0
   Porta.2 = 1
   Porta.4 = 1
   Waitms 150
   Porta.4 = 0
   Porta.2 = 0
   Porta.3 = 1
   Waitms 150
   Porta.3 = 0
   Waitms 150
   End Sub
   Return

Sub Lauflicht
   Print "Lauflicht"
   Porta.0 = 1
   Waitms 40
   Porta.0 = 0
   Porta.1 = 1
   Waitms 40
   Porta.1 = 0
   Porta.2 = 1
   Waitms 40
   Porta.2 = 0
   Porta.3 = 1
   Waitms 40
   Porta.3 = 0
   Porta.4 = 1
   Waitms 40
   Porta.4 = 0
   Porta.5 = 1
   Waitms 40
   Porta.5 = 0
   Porta.6 = 1
   Waitms 40
   Porta.6 = 0
   Porta.5 = 1
   Waitms 40
   Porta.5 = 0
   Porta.4 = 1
   Waitms 40
   Porta.4 = 0
   Porta.3 = 1
   Waitms 40
   Porta.3 = 0
   Porta.2 = 1
   Waitms 40
   Porta.2 = 0
   Porta.1 = 1
   Waitms 40
   Porta.1 = 0
   End Sub
   Return

Sub Allean
   Print "alle an"
   Porta.0 = 1
   Porta.1 = 1
   Porta.2 = 1
   Porta.3 = 1
   Porta.4 = 1
   Porta.5 = 1
   Porta.6 = 1
   Waitms 250
   End Sub
   Return

Sub Nacheinander
       Print "1.Led "
       Porta.0 = 1
       Porta.1 = 0
       Porta.2 = 0
       Porta.3 = 0
       Porta.4 = 0
       Porta.5 = 0
       Porta.6 = 0
       Waitms 100

       Print "2.Led "
       Porta.0 = 0
       Porta.1 = 1
       Porta.2 = 0
       Porta.3 = 0
       Porta.4 = 0
       Porta.5 = 0
       Porta.6 = 0
       Waitms 100

       Print "3.Led "
       Porta.0 = 0
       Porta.1 = 0
       Porta.2 = 1
       Porta.3 = 0
       Porta.4 = 0
       Porta.5 = 0
       Porta.6 = 0
       Waitms 100

       Print "4.Led "
       Porta.0 = 0
       Porta.1 = 0
       Porta.2 = 0
       Porta.3 = 1
       Porta.4 = 0
       Porta.5 = 0
       Porta.6 = 0
       Waitms 100

       Print "5.Led "
       Porta.0 = 0
       Porta.1 = 0
       Porta.2 = 0
       Porta.3 = 0
       Porta.4 = 1
       Porta.5 = 0
       Porta.6 = 0
       Waitms 100

       Print "6.Led "
       Porta.0 = 0
       Porta.1 = 0
       Porta.2 = 0
       Porta.3 = 0
       Porta.4 = 0
       Porta.5 = 1
       Porta.6 = 0
       Waitms 100

       Print "7.Led "
       Porta.0 = 0
       Porta.1 = 0
       Porta.2 = 0
       Porta.3 = 0
       Porta.4 = 0
       Porta.5 = 0
       Porta.6 = 1
       Waitms 100
       End Sub
       Return


End
Ich habe es auch mit versch. incr versucht, aber das gleiche Problem erhalten:

Code:
Declare Sub Lauflicht
Declare Sub Allean
Declare Sub Nacheinander
Declare Sub Startrek

Dim A As Byte
Dim B As Byte
Dim C As Byte
Dim D As Byte

Do

   If Pinb.0 = 1 Then

Incr A
If A < 10 Then Gosub Lauflicht

Incr B
If B < 10 Then Gosub Allean

Incr C
If C < 10 Then Gosub Nacheinander

Incr D
If D < 10 Then Gosub Startrek
Habt ihr Lösungsvorschläge oder Tipps, was ich falsch gemacht habe, bin echt dankbar.
Ich bekomme es nicht hin, dass das Unterprogramm "Nacheinander" hinter dem "Allean" und dahinter "Startrek" wirklich abgeschlossen für sich läuft.

Das einzigste gute daran: unkontrolliertes Software Multitasking, aber Multitasking