Rangkaian ;
Code List :
$regfile = "m16def.dat"
$crystal = 1000000
Config Kbd = Portb
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 ,Rs = Portc.0 , E = Portc.1
Config Portd = Output
Config Porta = Input
Dim A As Byte , B As Byte , Key As Byte , C As Byte , D As Byte , E As Byte
Cls
Cursor Off
B = 0
D = 1
Q:
Locate 1 , 1
Lcd "Putaran :"
Locate 2 , 1
Lcd "Kecept :"
Do
'************Read Keyboard
A = Getkbd()
If A > 15 Then
Goto Q
Else
Key = Lookup(a , Dta)
If Key <= 9 Then
B = B * 10
B = B + Key
'*************Direction
If D = 0 Then Lcd B
Waitms 270
Elseif Key = 10 Then
Locate 1 , 11
Lcd "Kiri"
C = 1
D = 0
B = 0
Elseif Key = 11 Then
Locate 1 , 11
Lcd "Kanan"
C = 2
D = 0
B = 0
'****************reset
Elseif Key = 13 Then
Cls
D = 1
B = 0
Portd.0 = 0
Portd.1 = 0
Waitms 50
Goto Q
'****************Enter key
Elseif Key = 14 Then
If D = 0 Then
Select Case C
Case 1 : Gosub R
Case 2 : Gosub T
End Select
End If
End If
End If
Wait 1
Loop
End
Dta:
Data 7 , 8 , 9 , 10 , 4 , 5 , 6 , 11 , 1 , 2 , 3 , 12 , 13 , 0 , 14 , 15
R:
Do
Portd = &B00000001 : Waitms B
Portd = &B00000011 : Waitms B
Portd = &B00000010 : Waitms B
Portd = &B00000110 : Waitms B
Portd = &B00000100 : Waitms B
Portd = &B00001100 : Waitms B
Portd = &B00001000 : Waitms B
Portd = &B00001001 : Waitms B
If Pina.0 = 1 Then
Locate 2 , 1
Lcd "Kecept:"
B = 0
Lcd B ; " "
Return
End If
Loop
T:
Do
Portd = &B00001001 : Waitms B
Portd = &B00001000 : Waitms B
Portd = &B00001100 : Waitms B
Portd = &B00000100 : Waitms B
Portd = &B00000110 : Waitms B
Portd = &B00000010 : Waitms B
Portd = &B00000011 : Waitms B
Portd = &B00000001 : Waitms B
If Pina.0 = 1 Then
Locate 2 , 1
Lcd "Kecept:"
B = 0
Lcd B ; " "
Return
End If
Loop
Tidak ada komentar:
Posting Komentar
Silahkan berkomentar !