28123 Parallax Inc, 28123 Datasheet - Page 187

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
Keeping Lists of On/Off Patterns
The
easier. The
example that uses the
There are two variables used in this command,
value
example, the
Terminal displays.
Example Program: SimpleLookup.bs2
' What's a Microcontroller - SimpleLookup.bs2
' Debug a value using an index and a lookup table.
' {$STAMP BS2}
' {$PBASIC 2.5}
value
index
index = 2
DEBUG ? index
LOOKUP index, [7, 85, 19, 167, 28], value
LOOKUP
stores the
LOOKUP index, [7, 85, 19, 167, 28], value
Decimal vs. Hexadecimal The basic digits in the decimal (base-10) number system are: 0,
1, 2, 3, 4, 5, 6, 7, 8, and 9. In the hexadecimal (base-16) number system the basic digits
are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, b, C, d, E, F. Base-16 is used extensively in both computer
and microcontroller programming. Once you figure out how to display the characters A
through F, you can further modify your program to count in hexadecimal from 0 to F.
Enter and run SimpleLookup.bs2.
Run the program as-is, with the
Try setting the
Re-run the program after each change to the
value from the list gets placed in the
Optional: Modify the program by placing the
loop that counts from 0 to 4.
LOOKUP
command makes writing code for 7-segment LED display patterns much
LOOKUP
VAR
VAR
7
. If
LOOKUP
command lets you “look up” elements in a list. Here is a code
command places
index
index
Byte
Nib
command:
variable equal to numbers between 0 and 4.
is
1
, the
index
19
value
into
value
variable set equal to 2.
index
stores
value
variable.
LOOKUP
and
85
index
, and that’s what the Debug
. Since
value
command in a
variable and note which
. If the
index
is 2, in this
index
FOR…NEXT
is 0,

Related parts for 28123