27220 Parallax Inc, 27220 Datasheet - Page 38

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
For example, this:
… actually performs the same function as:
but does it with just one line of code.
important aspect of microcontroller programming, and when we can save code space
we should – we’ll probably want or need that space later.
Write Code like a Pro
Note that even in this very simple program, we are following the style guidelines
detailed in “The Elements of PBASIC Style”. By using this professional style, the
program becomes somewhat self-documenting, requiring fewer comments, and it
allows the program to be modified far more easily. If, for example, we wanted to
change the LED pin assignment or the flash rate, we would only have to make small
changes to the declarations sections and not have to edit the entire listing. When
our programs grow to several hundred lines, using cleverly-named pin definitions and
constant values will save us a lot of time and frustration.
HIGH 0
DIR0 = 1
OUT0 = 1
A very common beginner’s error is this:
There is no need to manually configure the pin as an output as this function is part of the
HIGH command. While doing this won’t harm the program, it does consume valuable code
space. There are very few occasions when INPUT and OUTPUT are required for proper
program operation, as most PBASIC commands handle setting the pin’s I/O state.
OUTPUT 0
HIGH 0
Conservation of program space is an
' make P0 an output
' set P0 high

Related parts for 27220