910-90005 Parallax Inc, 910-90005 Datasheet - Page 17

KIT BASIC STAMP-PORTABLE DEVICE

910-90005

Manufacturer Part Number
910-90005
Description
KIT BASIC STAMP-PORTABLE DEVICE
Manufacturer
Parallax Inc
Series
BASIC Stamp®r
Type
Education Kitr
Datasheet

Specifications of 910-90005

Contents
Board, cable, components, manual and temperature sensor
For Use With/related Products
BASIC Stamp® 2 and Board of Education
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
Advanced LED Control
Another advantage to this program style is that we can cause the LED to follow the operation of a different value
within our program. We can do this because
can copy another bit-sized variable to it and cause the LED to follow the value of that variable.
Listing 1d is a bit advanced, but you can handle it. Take a look and then we'll go into all the details.
' {$STAMP BS2}
' Program: LED Blink.BS2 (Version D)
' Purpose: Blinks an LED connected to the BASIC Stamp (advanced)
' ---------------------------------------------------------------
LedPin
LedCtrl
blinkVal
blinkBit
' ---------------------------------------------------------------
Initialize:
Start:
In this program we'll need a couple variables. The first is called
remember that a Byte can hold values from zero to 255. The other variable is called
Nib (4 bits). Being a Nib,
blinkBit
the bit is a zero.
The main part of the program starts by opening the
DEBUG
inside our program as it's running.
The bulk of the code is two
blinkBit
256 times (0 to 255). This is where the action takes place.
Parallax, Inc. • BASIC Stamp HomeWork Board ver 1.1
LedCtrl = %1
DEBUG CLS
FOR blinkBit = 0 TO 7
NEXT
GOTO Start
FOR blinkVal = 0 TO 255
NEXT
' report
DEBUG Home
DEBUG "Blink Value = ", DEC blinkVal, " ", CR
DEBUG "Blink Bit = ", DEC blinkBit, CR
DEBUG CR
DEBUG "Blink Value = ", BIN8 blinkVal, CR
DEBUG "Blink Bit = ", REP " "\(7 - blinkBit), "^ "
' control the LED
LedPin = blinkVal.LowBit(blinkBit)
PAUSE 5
to point at a bit in
and will run eight times (0 to 7). For each iteration of
statement allows the BASIC Stamp send messages to the PC. This will let us know what's going on
VAR
VAR
VAR
VAR
Nib
Dir15
Byte
Out15
blinkVal
blinkBit
' make LED pin an output
FOR-NEXT
' blink control bit
' blink control value
' LED i/o pin control
' test all bits
' LED on/off control
' test all values
and the LED will follow that bit value. It will be on when the bit is a one; off when
can hold values from 0 to 15, but we only need it to go up to seven. We will use
loops; one nested inside the other. The outside loop is controlled by
Out15
DEBUG
is actually a bit-sized variable [a value that can change]. We
window and clearing it with
blinkBit
blinkVal
, the inner loop, controlled by
and it is defined as a Byte (8 bits). You'll
blinkBit
CLS
(clear screen). The
and is defined as a
blinkVal
will run
Page 17

Related parts for 910-90005