28129 Parallax Inc, 28129 Datasheet - Page 45

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
This
NEXT
time through the value of n increments to 2, and so on until n gets to 4. After completing
the 4
the
Program Listing 2.2 has a more complicated set of commands that gets repeated within
its
DO…LOOP
P0 is low,
high, then the program executes the next line, after the
The same technique is applied with the next two lines of code (and one comment), which
repeat themselves until a low signal is received.
The command
vacant space in the rightmost bit (the LSB) is automatically filled with a zero. Then the
bit value at pin P0 is loaded into the LSB position in the nibble. This is done using the
d=d+IN0
variable d. The second time through the loop, the value that was placed in the LSB gets
shifted left by one, so it ends up in bit-1. Meanwhile the next value sampled at P0 is
placed in the LSB slot. The shift and add process is repeated four times as each bit is
shifted into the byte.
Each time a new bit is shifted in, we use the
Each time the program gets to the
command, and the value of
out of the loop.
FOR…NEXT
NEXT
FOR…NEXT
th
command four times. The first time through the loop the value of n is 1, the second
pass, the program skips out of the loop and continues on to the line of code after
FOR n = 1 TO 4
command.
conditional loop. This loop is used to check the value at pin P0. If the value of
command, which adds the single bit measured at P0 to the value of the nibble
DO
LOOP UNTIL IN1=1
DO
LOOP UNTIL IN1=0
d = d << 1
d = d + IN0
LOOP UNTIL IN1=1
'Wait for high
'Wait for low
loop, and it is different from what we've seen before. It starts with a
d=d<<1
loop executes the PBASIC command between the
shifts all the bits in
n
is incremented, until it gets to 4. Finally the program breaks
sends the program back to
NEXT
command it returns to the
DEBUG
d
left by 1. When values are shifted, the
command to display the new value.
LOOP
instruction.
DO
. If the value at pin P1 is
FOR
FOR n = 1 TO 4
command and the

Related parts for 28129