from keypad import*
from lcdi2c import*
from utime import sleep
password="12345678" #set password
pass_temp='' # buffer for key in password
lcd_start()
string_write("start")
while 1:
key=getkey() # read from keypad
if key!=0: # if key is press
print("key press is:",key)
if key=='A':
cmd_wrt(0xc0)
string_write('hiii')
elif key=='C':
cmd_wrt(0x01)
pass_temp=''
elif key=='D':
if pass_temp==password:
cmd_wrt(0x01)
cmd_wrt(0xc0)
string_write('correct pass')
else:
cmd_wrt(0x01)
cmd_wrt(0xc0)
string_write('wrong pass')
pass_temp='' #clear password buffer
else:
pass_temp+=key #add key to pass_temp
print('pass_temp:',pass_temp)
cmd_wrt(0x01)
cmd_wrt(0xc0)
print('pass:',pass_temp)
for k in pass_temp:
string_write('*')
sleep(0.1)