English
Language : 

PAK-IV Datasheet, PDF (11/14 Pages) List of Unclassifed Manufacturers – Using the PAK-IV I/O Coprocessor
If you are using the Basic Stamp II or Basic Stamp IISX, you'll have no problems using
the ShiftIn and ShiftOut commands. Many Basic Stamp-compatible compilers have these
commands too. If you don't have access to these commands, don't worry. Here is some
simple code (written in simple PBasic) that shows the actions you have to take:
' B1 is the byte to shift
shiftoutput:
output datapin
for b7=0 to 7
' Set data pin to 0 or 1
low datapin
if (b1 & $80) <> $80 then so0
high datapin
so0:
b1=b1*2
' shift byte left
high clkpin
low clkpin
' could use pulsout
next
return
' B1 is byte to input byte
shiftinput:
input datapin
b1=0
for b7=0 to 7
b1=b1*2
b1=b1 | in15
high clkpin
low clkpin
' could use pulsout
next
return
You'll find a library of Basic Stamp II routines that allow you to access the PakIV on the
companion disk. Here is a simple program that generates random numbers while blinking
an LED connected to the PakIV's B4 pin and scanning a button on B3:
Xpin=1
gosub XBank
agn: xpin=4 ' toggle pin 4
gosub xtoggle
gosub xgetnumber ' get random number & print it
debug hex2 xoutvalue,cr
xpin=3
' check switch on pin 3
gosub xread
if xoutvalue=1 then nobz ' if switch up, no buzz
xpin=5 ' switch down: buzz on B5 speaker
xA=1000
xB=500
gosub XFreqout
nobz: goto agn ' do it all again