$regfile = "m32def.dat"
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pb.0 , Db5 = Pb.1 , Db6 = Pb.2 , Db7 = _
Pb.3 , E = Pb.5 , Rs = Pb.4
Config Porta = Output
Dim I As Byte , A As Byte , E As Byte
Cls
Dim B As Word
Dim C As Word
Dim D As Word
Dim K As Byte
Dim X As Byte
Config Kbd = Portd , Debounce = 100 , Delay = 70
Cls
Main0:
Do
K = Getkbd()
Loop Until K = 16
Do
K = Getkbd()
Loop Until K <> 16
If K = 15 Then
Goto Cal_isr
End If
If K = 14 Then
X = 1
Locate 2 , 1 : Lcd "Rotate right"
Goto Main0
End If
If K = 13 Then
X = 2
Locate 2 , 1 : Lcd "Rotate left"
Goto Main0
End If
B = B * 10
B = B + K
Locate 1 , 1 : Lcd B
Goto Main0
Cal_isr:
C = B / 7.2
D = B Mod 7.2
'---------------------------------- baghi mande---------------------
Select Case D
Case 0
Goto Main
Case 1
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Goto Main
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If
Case 2
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Goto Main
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If
Case 3
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If
Case 4
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If
Case 5
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Goto Main
End If
Case 6
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
Porta = 2
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 1000
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Goto Main
End If
Case 7
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Goto Main
End If
End Select
'------------------------------ adad asli----------------------
Main:
Select Case X
Case 1
For A = 1 To C
E = 128
For I = 1 To 4
Rotate E , Left
Porta = E
Waitms 100
Next I
Next A
Cls : Locate 1 , 1 : Lcd "stop_stop"
Do : Loop
Case 2
For A = 1 To C
E = 16
For I = 1 To 4
Rotate E , Right
Porta = E
Waitms 100
Next I
Next A
Cls : Locate 1 , 1 : Lcd "stop_stop"
Do : Loop
End Select