122-32000 Parallax Inc, 122-32000 Datasheet - Page 98

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
entirely of interpreted Spin code, it continues to reside only in main memory while a cog
running the Spin Interpreter (Cog 0 in this case) reads, interprets and effectively executes it.
No other cogs were started during boot up or during our application’s execution; the other
seven cogs remain in a dormant state consuming virtually no current at all. Later, we’ll
change our application to start other cogs as well.
Exercise 2: Output.spin - Constants
Let’s enhance our program a little. Suppose we want to make it easy to change the I/O pin
and the length of the delay used. As it is written currently, we’d have to find and change the
pin number in two places and the delay in yet another place. We can make it better by
defining those items in a separate place that is easy to find and edit. Look at the following
example and edit your code to match (we highlighted every new or modified element).
CON
PUB Toggle
The new
page 194.) In it, we created two symbols,
and 3,000,000 to them, respectively. We can now use the symbols
in the code to represent our constant values 16 and 3,000,000.
underscores (
not allowed there but underscores are allowed anywhere inside of constant values; this makes
large numbers more readable.
In the
the
constant values in place of their respective symbols. This makes it easy, later on, to change
the pin number or delay at will since we only have to change it up at the top of code in a
place that is easy to find and understand.
Try changing the
should now flicker at a rate of 12 blinks per second (24 toggles per second). You can also
Page 98 · Propeller Manual v1.0
Pin
Delay = 3_000_000
dira[Pin]~~
repeat
3_000_000
!outa[Pin]
waitcnt(Delay + cnt)
Toggle
CON
= 16
method, we replaced both occurrences of 16 with the symbol
_
block at the top of the code defines global constants for the object (see
with the symbol
) to separate the “thousands” groups in the number 3,000,000? Commas are
Delay
constant from 3,000,000 to 500,000 and download again; the LED
Delay
. When compiled, the Propeller Tool will use the
Pin
and
Delay
, and assigned the constant values 16
Pin
Notice that we used
and
Pin
Delay
, and replaced
elsewhere
CON
,

Related parts for 122-32000