psy
30.06.2007, 13:34
Bin vor paar tagen angefangen mich bissl in µC einzu arbeiten habe ne kleine anzeige mit einer 7 Segment programmiert der dauerhaft nacheinander ne zufällige Zahl anzeigt.
Mein Code ist aber ziemlich lang wollte mal fragen ob ihr tipps für mich habt den code bissl kleiner zu bekommen
$regfile = "m8def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Config Portc.5 = Output
Config Portc.4 = Output
Config Portc.3 = Output
Config Portc.2 = Output
Config Portc.1 = Output
Config Portc.0 = Output
Config Portb.5 = Output
Config Portb.4 = Output
1a Alias Portb.4
2a Alias Portb.5
4a Alias Portc.0
5a Alias Portc.1
6a Alias Portc.5
7a Alias Portc.4
9a Alias Portc.3
10a Alias Portc.2
Dim I As Word
Do
I = Rnd(10)
If I = 0 Then
1a = 0
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 1 Then
1a = 0
2a = 0
4a = 0
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 2 Then
1a = 1
2a = 0
4a = 1
5a = 1
6a = 0
7a = 0
9a = 1
10a = 1
Waitms 50
End If
If I = 3 Then
1a = 1
2a = 0
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
If I = 4 Then
1a = 1
2a = 1
4a = 0
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 5 Then
1a = 1
2a = 1
4a = 1
5a = 0
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
If I = 6 Then
1a = 1
2a = 1
4a = 1
5a = 0
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 7 Then
1a = 0
2a = 0
4a = 1
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 8 Then
1a = 1
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 9 Then
1a = 1
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
Loop
End
Mein Code ist aber ziemlich lang wollte mal fragen ob ihr tipps für mich habt den code bissl kleiner zu bekommen
$regfile = "m8def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 16000000
$baud = 9600
Config Portc.5 = Output
Config Portc.4 = Output
Config Portc.3 = Output
Config Portc.2 = Output
Config Portc.1 = Output
Config Portc.0 = Output
Config Portb.5 = Output
Config Portb.4 = Output
1a Alias Portb.4
2a Alias Portb.5
4a Alias Portc.0
5a Alias Portc.1
6a Alias Portc.5
7a Alias Portc.4
9a Alias Portc.3
10a Alias Portc.2
Dim I As Word
Do
I = Rnd(10)
If I = 0 Then
1a = 0
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 1 Then
1a = 0
2a = 0
4a = 0
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 2 Then
1a = 1
2a = 0
4a = 1
5a = 1
6a = 0
7a = 0
9a = 1
10a = 1
Waitms 50
End If
If I = 3 Then
1a = 1
2a = 0
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
If I = 4 Then
1a = 1
2a = 1
4a = 0
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 5 Then
1a = 1
2a = 1
4a = 1
5a = 0
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
If I = 6 Then
1a = 1
2a = 1
4a = 1
5a = 0
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 7 Then
1a = 0
2a = 0
4a = 1
5a = 1
6a = 0
7a = 1
9a = 0
10a = 0
Waitms 50
End If
If I = 8 Then
1a = 1
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 1
Waitms 50
End If
If I = 9 Then
1a = 1
2a = 1
4a = 1
5a = 1
6a = 0
7a = 1
9a = 1
10a = 0
Waitms 50
End If
Loop
End