
F2893 1-089 V3.0 ©MMVII Muscle Wires®
and Flexinol® are registered trademarks of Dynalloy
6.0 FrankenSerial Interface Input/Output Commands
Command Syntax Action, Stamp Syntax Example
High H [0-15] Turns the selected pin to an output and writes a 1 to it.
SEROUT 0, N2400,(“H”,9) ‘ Sets Interface pin 9
Low L [0-15] Turns the selected pin to an output and writes a 0 to it.
SEROUT 0, N2400,(“L”,b2) ‘ Clears Interface pin
‘ whose number is contained in b2.
Toggle T [0-15] Turns the selected pin to an output and toggles (inverts) it.
SEROUT 0, N2400,(“T”,9) ‘ Toggles Interface pin 9.
Bit B [0-15] Returns the state (0 or1) of the specified bit. Does not affect
the pins’ data direction settings (input or output).
SEROUT 0, N2400,(“B”,15) ‘ Request status of bit 15.
SERIN 0, N2400, b2 ‘ Get bit status in b2.
Analog A Returns a reading (0 to 255) from the ADC.
SEROUT 0, N2400,(“A”) ‘ Request ADC reading.
SERIN 0, N2400, b2 ‘ Get ADC data in b2.
Input I [0-15] Makes the specified pin number an input.
SEROUT 0, N2400,(“I”,b2) ‘ Makes the pin whose number
‘ is stored in b2, an input.
Output O [0-15] Makes the specifies pin number an output. Whatever state was
Last written to the pin (high or low) will be output when this occurs.
If the pin must be in a particular state, use High or Low to make it
SEROUT 0, N2400,(“O”,3) ‘ Makes pin 3 an output.
Direction, DB Writes the data direction registers of both of the Interface’s I/O
Both ports. A binary 1 in the data-direction register makes the
corresponding pin an output; a 0 makes it an input. The Interface
expects the lower port’s data direction first.
SEROUT 0, N2400,(“DB”,%00001111,%11111111)
‘ Make pins 0-3 outputs, 4-7 inputs. Make all of the
‘ upper port pins outputs.
Direction DL Writes the data direction register of the Interface’s lower I/O port as
SEROUT 0, N2400,(“DL”,255)
‘ Make all of lower port outputs (255 = %11111111).
Direction DH Writes the data direction register of the Interface’s higher I/O port
SEROUT 0, N2400,(“DH”,255)
‘ Make all of higher port outputs (255 = %11111111).
Read Both RB Reads both of the Interfaces I/O ports. Does not affect
the pins’ data direction settings (input or output). Interface returns
data as two bytes, lower byte first.
SEROUT 0, N2400,(“RB”) ‘ Request read of port.
SERIN 0, N2400, b2,b3 ‘ Get Interface data.
Read Lower RL Reads the Interface’s lower I/O port (pins 0-7) as in RB above.
SEROUT 0, N2400,(“RL”) ‘ Request read of port.
SERIN 0, N2400, b2 ‘ Get Interface data.
Read Higher RH Reads the Interface’s higher I/O port (pins 8-15) as in RB above.
SEROUT 0, N2400,(“RH”) ‘ Request read of port.
SERIN 0, N2400, b2 ‘ Get Interface data.
Command Syntax Action, Stamp Syntax Example
Write Both WB Writes both of the Interface’s I/O ports. Does not affect the pins’
data direction settings (input or output). If a pin is set to input at the
time of a write, it will not be affected until I is made an output.
SEROUT 0, N2400,(“WB”, b2, b3) ‘ Write contents of
‘ variable b2 to lower port, b3 to higher.
Write Lower WL Writes the interface’s lower I/O port (pins 0-7) as in WB above.
SEROUT 0, N2400,(“WL”, 255) ‘ Write 1s to all pins
Write Higher WH Writes the interface’s higher I/O port (pins 8-15) as in WB above.
SEROUT 0, N2400,(“WH”, 255) ‘ Write 1s to all pins
Sleep S Puts the Interface to sleep. At intervals of 18 ms to 2.3 seconds,
the Interface will check its serial line for a high, signaling it to wake
SEROUT 0, N2400,(“S”, 0) ‘ Sleep. Look for
Reset * Returns the Interface’s I/O pins to their power-up configuration;
All inputs, and all internal latches cleared to 0s. Useful during
Programming to set the interface to a know state. However, if the
Stamp is interrupted in the middle of a multipart command, it may
take as may as three resets to finish the interrupted command and
actually reset the interface.
SEROUT 0, N2400,(“*”) ‘ Reset all pins/directions.
Converting the program examples for use with the BASIC Stamp 2
The BASIC Stamp 2 (BS2) has Serin and Serout instructions that are similar to those of the BS1, but offer
more options. First of all, you can send and receive data at arbitrary data rates up to 50,000 bps, so it’s up to
you to calculate the bit time and other communication parameters, called “baudmodes” in PBASIC. Here are
the baudmodes that apply to communication with the FrankenSerial Interface.
$418d ‘Inverted, 2400 baud.
$4054 ‘Inverted, 9600 baud.
We won’t duplicate the entire instruction table here, just a couple of examples. Suppose you wanted to toggle
pin 10 of the Interface, and that the Interface’s serial pin is connected to BS2 pin 0. Assuming the Interface is
set for 9600 bps (jumper installed on the posts marked BPS), the instruction would be:
serout 0,$4054,[“T”,10] ‘Toggle pin 10.
The same pattern applies to all of the other output-only instructions.
To issue an instruction that expects a serial response (B for bit and A for Analog), you perform Serout to send
the instruction followed by Serin to get the response. For instance, to read the state of Interface bit 15,
assuming BS2 pin 0 for serial communication, 2400 baud (no jumper at BPS), and the existence of a byte
variable named “result,” your instructions would be:
serout 0,$418d,[“B”,15] ‘Request state of bit 15.
Serin 0, $418d, [result] ‘get the response
The BS2 flavors of Serin and Serout have many other options. See the Parallax documentation for details.