28123 Parallax Inc, 28123 Datasheet - Page 301

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
LOOP UNTIL index = 5
DEBUG CR, "Password is correct;", CR,
END
Your Turn – Modifying Passwords
Modifying Password Checker for Use in a Larger Program
The goal is to make it easy to fit the PasswordChecker.bs2 program into the example
program from Activity #3. Two things will help. First, the password checking program
should be modified so that it does most of its work in a subroutine. The different parts of
the program should also be labeled with commented headings to help make it clear how
to combine the two programs.
Example Program: ReusablePasswordChecker.bs2
ReusablePasswordChecker.bs2 works the same as PasswordChecker.bs2, but it now uses
a subroutine to do the work, and it has been reorganized into labeled sections.
DEBUGIN STR userEntry \5
FOR index = 0 TO 4
NEXT
IF index <> 5 THEN
ENDIF
READ Password + index, temp
IF temp <> userEntry(index) THEN EXIT
DEBUG CR,"Password not correct.", CR
Modify the
password.
By changing five different values in the program, you can also modify it so
that it accepts a four character password instead of a five character password.
Verify that the program still works the same as PasswordChecker.bs2.
Examine how the
"program can continue..."
Password DATA
DO…LOOP UNTIL
directive so that it uses a different five character
code block was placed into a subroutine.
' Get user input password.
' Check array against DATA
' Get next password char
' Compare to user input,
' exit if not equal.
' If exit, then index not equal
' to 5 and pass is not correct.
' Only get out of loop when
' index = 5.
' Program can move on when
' password is correct.

Related parts for 28123