'Würfel Version 1.00 'By Malte Marwedel www.marwedels.de/malte 'Für ATMEL AT90S2343 oder ATMEL ATiny22 $crystal = 500000 Config Portb = &B00001111 Dim Taste As Word Dim Zahl As Byte Dim Oldzahl As Byte Dim Standby As Word Dim Fundurch As Byte Dim Zweidrei As Bit Zahl = 1 Main: Zweidrei = Not Zweidrei If Pinb.4 = 1 Then Goto Zufall End If Waitms 1 Incr Standby If Standby = 60000 Then Goto Fun1 End If Goto Main Zufall: Set Portb.0 Set Portb.1 Set Portb.2 Set Portb.3 If Pinb.4 = 1 Then Oldzahl = Zahl If Oldzahl = 6 Then Zahl = 1 End If If Oldzahl = 5 Then Zahl = 6 End If If Oldzahl = 4 Then Zahl = 5 End If If Oldzahl = 3 Then Zahl = 4 End If If Oldzahl = 2 Then Zahl = 3 End If If Oldzahl = 1 Then Zahl = 2 End If Else Waitms 10 If Pinb.4 = 1 Then Goto Zufall End If Goto Zeige End If Goto Zufall Zeige: Gosub Ledaus Waitms 200 If Zahl = 1 Then Set Portb.3 End If If Zahl = 2 Then If Zweidrei = 0 Then Set Portb.0 Else Set Portb.2 End If End If If Zahl = 3 Then Set Portb.3 If Zweidrei = 0 Then Set Portb.0 Else Set Portb.2 End If End If If Zahl = 4 Then Set Portb.0 Set Portb.2 End If If Zahl = 5 Then Set Portb.0 Set Portb.2 Set Portb.3 End If If Zahl = 6 Then Set Portb.0 Set Portb.1 Set Portb.2 End If Waitms 200 Standby = 0 Goto Main Fun1: Gosub Ledaus Fun2: 'Drehen For Fundurch = 0 To 25 Set Portb.0 Reset Portb.1 Reset Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Reset Portb.0 Set Portb.1 Reset Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Reset Portb.0 Reset Portb.1 Set Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Next Fun3: 'Hin und her For Fundurch = 0 To 20 Set Portb.0 Reset Portb.1 Reset Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Reset Portb.0 Set Portb.1 Reset Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Reset Portb.0 Reset Portb.1 Set Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Reset Portb.0 Set Portb.1 Reset Portb.2 If Pinb.4 = 1 Then Goto Zufall End If Waitms 100 Next Goto Fun2 Ledaus: Reset Portb.0 Reset Portb.1 Reset Portb.2 Reset Portb.3 Return