something like : lcd will display "Type Your Name" then user will type name using keypad. then the name will be save into eeprom. and can be read to display in lcd.
something like : lcd will display "Type Your Name" then user will type name using keypad. then the name will be save into eeprom. and can be read to display in lcd.
'demo
Dim pntr As Byte 'index pointer
Dim chr(6) As Byte '' keyboard entry buffer [array]
Dim mem As Byte 'address location in eeprom
'you should arrange so as that each character is typed in, it loads the chr ARRAY buffer
'Test the character for CR code 0x13, then transfer to the EEPROM
'simulated user typed input.
chr(1) = "T"
chr(2) = "E"
chr(3) = "X"
chr(4) = "T"
chr(5) = 0x13
mem = 0x00' memory address start
For pntr = 1 To 5
Write mem, chr(pntr)
mem = mem + 1
Next pntr
End
Define CONF_WORD = 0x3f72
Define CLOCK_FREQUENCY = 12
AllDigital
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 0
Define LCD_RSREG = PORTE
Define LCD_RSBIT = 0
Define LCD_RWREG = PORTE
Define LCD_RWBIT = 1
Define LCD_EREG = PORTE
Define LCD_EBIT = 2
Define LCD_READ_BUSY_FLAG = 1
'For Keypad
Symbol raw1 = RD7
Symbol raw2 = RD6
Symbol raw3 = RD5
Symbol raw4 = RD4
Symbol col1 = RD0
Symbol col2 = RD1
Symbol col3 = RD2
Symbol col4 = RD3
TRISD = 0xf0
TRISB = 0
Lcdinit
Dim button As Byte
Dim digit As Byte
Dim pass As Byte
Dim error As Bit
Dim mem As Byte
start:
Lcdcmdout LcdClear
Lcdout "ALARM SYSTEM"
Lcdcmdout LcdClear
Lcdout "New Password:"
Lcdcmdout LcdLine2Home
Lcdout "----"
For digit = 1 To 4 '4 digit password
Gosub get_button
pass(digit) = button
Lcdcmdout LcdLine2Pos(digit) 'replace '-' with key type
Lcdout #button
button = 0
Next digit
'go to write input data
Gosub write_data
Lcdcmdout LcdClear
Lcdout "Password Saved"
WaitUs 2000
'Test Password
Gosub check_password
Goto start
End
check_password:
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Home
Lcdout "Type Password"
For digit = 1 To 4 '4 digit password
Gosub get_button
pass(digit) = button
Lcdcmdout LcdLine2Pos(digit)
Lcdout #button
button = 0
Next digit
'???? Here how to check the input password is same with saved password, error = 1 if wrong password.... some code for me?
If error = 1 Then
Lcdout "Access Denied"
WaitUs 2000
Goto check_password
Else
Lcdout "Access verified"
Endif
Return
write_data:
mem = 0x00 'memory address start
For digit = 1 To 4
Write mem, pass(digit)
mem = mem + 1
Next digit
Return
get_button:
While button = 0
button = 0
col1 = 1
If raw1 = 1 Then button = 1
If raw2 = 1 Then button = 5
If raw3 = 1 Then button = 9
If raw4 = 1 Then button = 13
col1 = 0
col2 = 1
If raw1 = 1 Then button = 2
If raw2 = 1 Then button = 6
If raw3 = 1 Then button = 10
If raw4 = 1 Then button = 14
col2 = 0
col3 = 1
If raw1 = 1 Then button = 3
If raw2 = 1 Then button = 7
If raw3 = 1 Then button = 11
If raw4 = 1 Then button = 15
col3 = 0
col4 = 1
If raw1 = 1 Then button = 4
If raw2 = 1 Then button = 8
If raw3 = 1 Then button = 12
If raw4 = 1 Then button = 16
col4 = 0
Wend
'?????here the code wait for button release before return.... some code for me??? :)
Return
there is some code from my program... not finish yet... need some help from you all... thank you
col4 = 1
If raw1 = 1 Then button = 4
If raw2 = 1 Then button = 8
If raw3 = 1 Then button = 12
If raw4 = 1 Then button = 16
col4 = 0
Wend
While PORTD <> 0
Wend
'?????here the code wait for button release before return.... some code for me??? :)
Return
col4 = 1
If raw1 = 1 Then button = 4
If raw2 = 1 Then button = 8
If raw3 = 1 Then button = 12
If raw4 = 1 Then button = 16
col4 = 0
Wend
While PORTD <> 0
Wend
'?????here the code wait for button release before return.... some code for me??? :)
Return