Specifications

BASIC Stamp II
Page 292 • BASIC Stamp Programming Manual 1.8 • Parallax, Inc.
both functions are rolled into the pin variables, such as “pin7.” So in
the situation outlined above and shown in figure I-10, the BS1 would
produce a single negative pulse and leave the pin output high when
done.
PULSOUT 7,5
+5V
10k
pin 7 O-scope
ab
pin 7 in input mode
(DIR7 = 0,
OUT7 = 0)
but held high by
resistor to +5V
(instruction
executes)
pin changes to
output (~6µs)
10µs positive pulse
pin remains
output-low
(DIR7 = 1,
OUT7 = 0)
pin 7 connected to
oscilloscope as
shown
Figure I-10
To make the BS2 work the same way, copy the state of the pin’s INS bit
to its OUTS bit before Pulsout:
OUT7 = IN7 ' Copy input state to output driver.
PULSOUT 7,5 ' 10-us pulse on pin 7.
Now the instruction would pulse low briefly, then return output-high,
just like the BS1. Of course, BS1 Pulsout works in units of 10µs, so you
would have to adjust the timing to make an exact match, but you get
the idea.
Demo Program
This program blinks an LED on for 10ms at 1-
second intervals. Connect the LED to I/O pin 0
as shown in figure I-11.
high 0 ' Set the pin high (LED off).
again:
pause 1000 ' Wait one second.
PULSOUT 0,5000 ' Flash the LED for 10 ms.
goto again ' Repeat endlessly.
220
LED
I/O pin
+5V
Figure I-11