Mcu Projectpbcb
Mcu Projectpbcb
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 = P1.6 , Db7 = P1.7 , E =
P3.5 , Rs = P3.7
Dim S1 As String * 1
Dim S2 As String * 8 'Character of key
pressed
Dim S3 As String * 8
P3.0 = 0
P3.1 = 0
Reset P3.6
Lcdinit
Wait 1
C = 17
Cls
Lcd " Enter Password"
Locate 2 , 2
Wait 1
Do
Gosub Keyscan
If A = 1 Then
If C < 10 Then
If Len(s3) < 8 Then
S1 = Str(c)
S2 = S3
S3 = S2 + S1
Locate 2 , 2
Lcd S3
End If
Waitms 250
Waitms 250
C = 17 : A = 0
Elseif C = 14 Then
L = Len(s3)
If L > 1 Then
L = L - 1
S2 = Left(s3 , L)
S3 = S2
Elseif L = 1 Then
S3 = ""
End If
Locate 2 , 2
Lcd " "
Locate 2 , 2
Lcd S3
Waitms 250
Waitms 250
C = 17 : A = 0
Elseif C = 15 Then
If S3 = "12345" Then
If P3.1 = 1 Then
P3.1 = 0
Cls
Lcd " MOTOR OFF"
Elseif P3.1 = 0 Then
P3.1 = 1
Cls
Lcd " MOTOR ON "
End If
Wait 1
S3 = ""
Cls
Lcd " Enter Password"
Locate 2 , 2
End If
End If
End If
Loop
End
Keyscan:
'This is an simple 4x4 keyboard decoder with A to D and the * and # commented out
'------------------------------
Return
2_but:
C = 2
A = 1
Return
3_but:
C = 3
A = 1
Return
4_but:
C = 4
A = 1
Return
5_but:
C = 5
A = 1
Return
6_but:
C = 6
A = 1
Return
7_but:
C = 7
A = 1
Return
8_but:
C = 8
A = 1
Return
9_but:
C = 9
A = 1
Return
Star_but:
C = 14
A = 1
Return
0_but:
C = 0
A = 1
Return
Hash_but:
C = 15
A = 1
Return