28129 Parallax Inc, 28129 Datasheet - Page 87

TEXT BASIC ANALOG & DIGITAL

28129

Manufacturer Part Number
28129
Description
TEXT BASIC ANALOG & DIGITAL
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28129

Style
Book
Title
Basic Analog and Digital
Contents
Basic Analog and Digital Text
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
begin to create more complex programs, you may find yourself looking for ways to get
the most out of the least code.
There are two registers that we need to set to control output on a specific group of I/O
lines. The first register is called “direction”. The command “output” sets the direction as
an “output”. Conversely, “input” sets the I/O line up as input. The second is the “data”
register. If the I/O pin has been set up as an output, then this register’s “data” can be set
to either 0 or 1. This in turn sends either a low or high signal to that pin, and the
measured output will either be 0 or 5 volts.
Certain commands in PBASIC allow us to directly address its I/O lines as a word (16
individual bits), two bytes (two sets of 8 individual bits) or as 4 nibbles (four sets of four
individual bits). To modify our code, we want to address a nibble at a time, and the four
bits that we’re using are P4-P7. According to the BASIC Stamp Manual (which you
should have a copy of by now - it’s free download at www.parallax.com and printed
copies are not expensive) the group “P4-P7” is called nibble “b”. The next set of four
(P8-P11) is nibble “c”, and so on.
Let’s try using this in a program and figure out how it works. Rewrite the DAC:
subroutine in Program Listing 4.1 as follows:
Figure 4-5 shows the output is identical to the previous version of the
did the same job with two lines of code instead of eight.
DAC:
RETURN
n = 11
DIRB = 15
OUTB = n
DAC
subroutine. We

Related parts for 28129