28123 Parallax Inc, 28123 Datasheet - Page 299

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
Programming a Password Checker
You can save a password in a PBASIC program by using a
You will need a few variables for storing other values in the program:
If you are using a five character password, there is a special kind of variable declaration
(called an array declaration) that you use to declare five variables with the same name.
Now you have five byte variables named userEntry:
userEntry(2)
The
into an array. For example, you can use:
If you type five characters in the Debug Terminal’s Transmit Windowpane, the first will
get placed in
There is a PBASIC keyword called
check a password, you can use an
the loop to end early if not all the characters are identical. When the loop ends early, it
means that
password was not correct:
DEBUGIN
Password
index
temp
userEntry
DEBUGIN STR userEntry \5
FOR index = 0 TO 4
NEXT
IF index <> 5 THEN
ENDIF
The same as: This
"
READ Password + index, temp
IF temp <> userEntry(index) THEN EXIT
DEBUG CR,"Password not correct.", CR
s
index
"
,
userEntry(0)
command has a formatter called
,
"
!
userEntry(3)
".
has not counted all the way up to five, which in turn means the
DATA
VAR
VAR
VAR
DATA
, the second will get placed in
, and
directive is the same as
IF…THEN
userEntry(4)
EXIT
"pass!"
Nib
Byte
Byte(5)
that you can use to break out of a loop. To
statement with an
STR
.
that automatically loads characters
Password DATA
userEntry(0)
userEntry(1)
DATA
EXIT
directive. For example:
command to cause
,
"
userEntry(1)
p
, etc.
"
,
"
a
"
,
"
s
"
,
,

Related parts for 28123