Shop OBEX P1 Docs P2 Docs Learn Events
Help On password,stuck — Parallax Forums

Help On password,stuck

ClineCline Posts: 36
edited 2006-07-01 14:19 in BASIC Stamp
Hey everyone,

I had an earlier post on memory/smaller program, Thanks for all the help. Here is the code i have written so far, I would like help on condensing it. I omitted the main routine,but i would like to change how i enter the password to enter the program. I have to type the pasword into the debug terminal, i would like to have it on the keypad and it show up on the lcd,· Iv tried all i know, just cant get it together,

thanks guys, after this i will get the memory and hopefully this project will start taking shape,,
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG"Micro Board System " , CR
'
[noparse][[/noparse] Declarations ]
'LCD
'Interface
tx················· PIN······· 0······ 'Transmit pin to LCD
Rx················· PIN······· 1······ 'Receive pin from LCD
Baud··············· CON······· 84····· 'Equals baud rate of 9.6k
Int················ CON······· 254···· 'place befor each instruction
'Commands
Auto_Wrap_On······· CON······· 67·····
Auto_Wrap_Off······ CON······· 68·····
Auto_Scroll_On····· CON······· 81·····
Auto_Scroll_Off···· CON······· 82·····
Cursor_pos········· CON······· 71····· 'Needs Column and row
Cur_home··········· CON······· 72·····
Under_Line_On······ CON······· 74·····
Under_Line_Off····· CON······· 75·····
Blinking_On········ CON······· 83·····
Blinking_Off······· CON······· 84·····
Cursor_Left········ CON······· 76·····
Cursor_Right······· CON······· 77·····
Clear_screen······· CON······· 88·····
Contrast··········· CON······· 80····· 'Needs level $00 to $FF
Backlight_On······· CON······· 66····· 'SET $00 = on, minute max $FF
Backlight_Off······ CON······· 70····· ''See LCD manual for more detail
GP_pin_off········· CON······· 86····· 'NEEds $01 to $06 for pin #
GP_pin_on·········· CON······· 87····· 'NEEds $01 to $06 for pin #
'Key pad
Auto_repeat_on····· CON······· 126···· '$00 = resend $01 = key up/down
Auto_repeat_off···· CON······· 96·····
Auto_Trans_On······ CON······· 65····· 'Sends key press data immediately
Auto_Trans_Off····· CON······· 79····· 'STORE 10 key presses until polled
Clear_buffer······· CON······· 69····· 'See LCD manual for more detail
Poll_keypad········ CON······· 38····· 'Polls LCD for last key press
Debounce_time······ CON······· 85····· 'Set in 6.554ms units default 52mS
'Bar graphs
Wide_vert_bar······ CON······· 118···· 'Initialize wide vertical bar
Naro_vert_bar······ CON······· 115···· 'Initialize narrow vertical bar
Draw_vert_bar······ CON······· 61·····
Horz_bar··········· CON······· 104···· 'Initialize horizontal bar
Draw_horz_bar······ CON······· 124
Cusstom_char······· CON······· 78·····
Large_dig·········· CON······· 110
Place_lrg_dig······ CON······· 35····· 'Column $01/$12 digit $00/$09
'data directives
Password··········· DATA··· "33722"
'variable declarations
index······· VAR·· Nib
userentry··· VAR·· Byte(5)
·temp··············· VAR······· Byte··· 'Working variable
Key················ VAR······· Byte··· 'key storage variable
io_pin············· VAR······· Byte··· 'GP I/O variable
'initialization routine
GOSUB check_password
'main routine
DEBUG CR, "complete"
END
'subroutine
check password
check_password:
·DO
· DEBUG CR,"Enter Password"
· DEBUGIN STR userentry \5
· FOR index=0 TO 4
· READ password + index, temp
· IF temp <> userentry(index) THEN EXIT
· NEXT
· IF index <> 5 THEN
· DEBUG CR, "password incorrect"
· ENDIF
· LOOP UNTIL index=5
· DEBUG CR, "accessed"
'display
·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]······· 'Command Prefix
SEROUT 0, 84, [noparse][[/noparse]"· Mainframe Online "]
PAUSE 2000
·SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
·SEROUT 0, 84, [noparse][[/noparse]"····· A.W.O.T. "]
·SEROUT 0, 84, [noparse][[/noparse]"·········· SYSTEMS· "]
·PAUSE 2000
· SEROUT 0, 84, [noparse][[/noparse]Int,Clear_screen]
· SEROUT Tx,Baud,[noparse][[/noparse]"DESIGNED BY ",Int,Cursor_pos,1,2,
·············· "Charles Cline", Int,Cursor_pos,1,4,"Starting Sub-Program"]
· '
[noparse][[/noparse] Initialization ]
PAUSE 4000····························· 'Waits for 250ms
Initialize:··························· 'label
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····· 'Clears screen
SEROUT Tx,Baud,[noparse][[/noparse]Int,Auto_trans_off]··· 'Turns off buffer for key pad
'Sets up text on LCD
SEROUT Tx,Baud,[noparse][[/noparse]"Press 0-9 or A to",Int,Cursor_pos,1,2,
·············· "POWER on all systems",
·············· Int,Cursor_pos,1,3,"B to turn them all",
·············· Int,Cursor_pos,1,4,"off.C to Exit,D=MP"]
'
[noparse][[/noparse] Main Routine ]
In_Put:······························· 'Label
GOSUB key_pad························· 'Jumps to key pad polling routine
· IF key = "#" THEN I_O_On············ 'coMPares key and jumps if true
· IF key = "*" THEN I_O_Off··········· 'coMPares key and jumps if true
GOTO In_Put··························· 'Jumps to listed label

'
[noparse][[/noparse] Subroutines ]
I_O_Off:······························ 'Label
'Sends text to LCD
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
·············· "Is now turned off. "]
SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin] 'SetS I/O pin to off
PAUSE 2000···························· 'PAUse for 2000ms
GOTO Initialize······················· 'JUmps to listed label
I_O_On:······························· 'Label
'Sends text to LCD
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"I/O pin ",DEC io_pin,Int,Cursor_pos,1,2,
·············· "Is now turned on. "]
SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin]· 'listed I/O pin to on
PAUSE 2000···························· 'Pause for 2000ms
GOTO Initialize······················· 'Jumps to listed label
key_pad:······························ 'Label
SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
· IF temp = 0 THEN key_pad············ 'coMPares key and jumps if true
·· GOSUB Convert······················ 'JumP to listed label
· IF temp = "A" THEN All_On··········· 'coMPares key and jumps if true
· IF temp = "B" THEN All_Off·········· 'coMPares key and jumps if true
·IF temp = "C" THEN Exit_p
·IF temp = "D" THEN Main_P
·IF temp= "1" THEN One_p
·IF temp= "2" THEN Two_p
· IF temp= "3" THEN Three_p
IF temp= "4" THEN Four_p
· IF temp= "5" THEN Five_p
· IF temp= "6" THEN Six_p
· IF temp= "7" THEN Seven_p
· IF temp= "8" THEN Eight_p
· IF temp= "9" THEN Nine_p
· IF temp= "0" THEN zero_p
· IF temp > 54 OR temp < 49 THEN Error 'coMPares key and jumps if true
'Displays in ASCll
io_pin = temp - 48···················· 'Converts ASCll to decimal
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen,"Please press an * to",Int,Cursor_pos,1,2,
·············· "turn off Pin ",DEC io_pin," or #",Int,Cursor_pos,1,3,
·············· "to turn it on."]
Wait_For_key:························· 'Label
'Displays character typed in ASCll
SEROUT Tx,Baud,[noparse][[/noparse]Int,Poll_keypad]······ 'Request last key press from LCD
SERIN Rx,Baud,[noparse][[/noparse]temp]·················· 'Store key press in temp
IF temp = 0 THEN Wait_For_key········· 'If no key Press jump to label
· GOSUB Convert······················· 'Jump to listed label
· key = temp·························· 'StorES temp in to key variable
RETURN································ 'Jump to next line UNDER last gosub
Convert:······························ 'Label
'Table to convert variable
LOOKDOWN· temp,[noparse][[/noparse]66,67,68,69,71,72,73,74,76,77,78,79,81,82,83,84],temp
'Table to convert variable
LOOKUP··· temp,[noparse][[/noparse]"D","#","0","*","C","9","8","7","B","6","5","4","A","3",
·············· "2","1"],temp
RETURN································ 'Jump to next line UNDER last gosub
All_On:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]······························ 'Label
SEROUT Tx,Baud,[noparse][[/noparse]"All on"]············· 'Displays text
FOR io_pin = 1 TO 6··················· 'CyCLEs io_pin variable fro 1 to 6
·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_On,io_pin] 'SETs listed I/O pin to on
NEXT·································· 'cycles until io_pin = 6
PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
All_Off:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]····························· 'Label·· INCOmPlETE
SEROUT Tx,Baud,[noparse][[/noparse]"All Off"]············ 'Displays text
FOR io_pin = 1 TO 6··················· 'CYCles io_pin variable fro 1 to 6
·SEROUT Tx,Baud,[noparse][[/noparse]Int,GP_Pin_Off,io_pin]'Sets listed I/O pin to off
NEXT·································· 'cycles until io_pin = 6
PAUSE 1000···························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
Error:································ 'Label
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]···· 'Clears screen
'Displays text
·SEROUT Tx,Baud,[noparse][[/noparse]"······· ERROR··············· "]
·PAUSE 1000··························· 'Pauses for 1000 ms or 1 second
GOTO Initialize······················· 'Jumps to listed label
·· ' dont know where these go
Exit_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
··· SEROUT Tx,Baud,[noparse][[/noparse]"··· ..WARNING..",Int,Cursor_pos,1,2,
·············· "*All SYSTEMS LOCKED*" ]
·············· PAUSE 500
·· GOTO check_password

·· Main_p:
··· SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Main· Program "]
·· PAUSE 500
···· GOTO Initialize
··· One_p:
· SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Camera· Program "]
·· PAUSE 1000
·· GOTO Initialize
·Two_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"I.R.Tracking Program "]
·· PAUSE 1000
· GOTO Initialize
·Three_p:
·SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Thermal· Program "]
·· PAUSE 1000
·· GOTO Initialize
Four_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"Bluetooth Program "]
·· PAUSE 1000
·· GOTO Initialize
Five_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Five· Program "]
·· PAUSE 500
·· GOTO Initialize
Six_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Six· Program "]
·· PAUSE 500
·· GOTO Initialize
Seven_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Seven· Program "]
·· PAUSE 500
·· GOTO Initialize
Eight_p:
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Eight Program "]
·· PAUSE 500
·· GOTO Initialize
Nine_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Nine Program "]
·· PAUSE 500
·· GOTO Initialize
· zero_p :
SEROUT Tx,Baud,[noparse][[/noparse]Int,Clear_screen]
·· SEROUT Tx,Baud,[noparse][[/noparse]"··· Zero Program "]
·· PAUSE 500
·· GOTO Initialize

·
Sign In or Register to comment.