Here is another approach that allows you to wait for all of the characters to be entered before testing the password.
It also makes use of arraywrite to enter the Master Password.
Code:
DEFINE OSC 4 'Set oscillator in MHz
'OSCCON = $60 '4 Megs
DEFINE HSER_RCSTA 90H 'Set receive status and control
DEFINE HSER_TXSTA 24H 'Set transmit status and control
DEFINE HSER_BAUD 9615 'Baud Rate
MasterPass var byte[9]
pass var byte[9]
PassTest var bit
i var byte
' ADCON1 = 7 ' Turns Analogs off
' CMCON0 = 7 'Disable both comparators
' ANSEL = 0 ' Set all analog pins to digital
arraywrite MasterPass,["299792458"]
main:
'Test for 299792458
PassTest = 1
for i = 0 to 8
pass[i] = 0
next i
hserout [":- "]
for i = 0 to 8
hserin 65535, bed, [pass(i)]
hserout [pass(i)]
next i
'Check Password with Master
for i = 0 to 8
if pass(i) <> MasterPass(i) then PassTest = 0
next i
if PassTest = 1 then correct
hserout [13,10,"NO WAY!!",13,10]
goto main
correct:
hserout [13,10,"Correct!",13,10]
goto main
bed:
hserout ["Timeout",13,10]
bye:
goto main
Bookmarks