Basic stamp homework board manual
Parallax, Inc. • BASIC Stamp HomeWork Board ver 1.1 Page 16
Outs
is a zero, the associated output pin will be low (0 volts). When a bit in Outs is one, the associated output pin
will be high (5 volts).
So,
HIGH 15 is the same as:
Dir15 = 1
Out15 = 1
and
LOW 15 is the same as:
Dir15 = 1
Out15 = 0
You'll remember from the variables overview in Chapter XX that Dirs and Outs can be accessed as a Word (16
bits), as two Bytes (8 bits), as four Nibbles (4 bits) or as 16 individual Bits. So,
Dir15 corresponds to bit 15 of the
Dirs register.
The advantage of going to this depth is that we can gain more flexibility and control over our programs –
especially in terms of readability (this aspect will become much more important as our programs grow). Take a
look at Listing 1c. Notice how we really don't need any comments to explain what's going on? Pretty cool, huh?
' {$STAMP BS2}
' Program: LED Blink.BS2 (Version C)
' Purpose: Blinks an LED connected to the BASIC Stamp
' ---------------------------------------------------------------
LedPin VAR Out15 ' LED on/off control
LedCtrl VAR Dir15 ' LED i/o pin control
On CON 1
Off CON 0
' ---------------------------------------------------------------
Initialize:
LedCtrl = %1 ' make LED pin an output
Start:
LedPin = On
PAUSE 500
LedPin = Off
PAUSE 500
GOTO Start