BASIC stamp manual v2.2
5: BASIC Stamp Command Reference – SERIN 
BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com • Page 401 
The SERIN command can also be configured to wait for specified data 
before it retrieves any additional input. For example, suppose a device 
that is attached to the BASIC Stamp is known to send many different 
sequences of data, but the only data you desire happens to appear right 
after the unique characters, “XYZ”. The BS1 has optional Qualifier 
arguments for this purpose. On all BS2 models, a special formatter called 
WAIT can be used for this.  
SYMBOL serData = B2 
SERIN 1, N2400, ("XYZ"), #serData 
-- or -- 
serData VAR Byte 
SERIN 1, 16780, [WAIT("XYZ"), DEC serData] 
The above code waits for the characters “X”, “Y” and “Z” to be received, 
in that order, and then it looks for a decimal number to follow. If the 
device in this example were to send the characters “XYZ100” followed by 
a carriage return or some other non-decimal numeric character, the serData 
variable would end up with the number 100 after the SERIN line finishes.  
If the device sent some data other than “XYZ” followed by a number, the 
BASIC Stamp would continue to wait at the SERIN command. 
The BS1 will accept an unlimited number of Qualifiers. All BS2 models will 
only accept up to six bytes (characters) in the WAIT formatter. 
Keep in mind that when we type “XYZ” into the SERIN command, the 
BASIC Stamp actually uses the ASCII codes for each of those characters for 
its tasks. We could also have typed: 88, 89, 90 in place of “XYZ” and the 
code would run the same way since 88 is the ASCII code for the “X” 
character, 89 is the ASCII code for the “Y” character, and so on. Also note, 
serial communication with the BASIC Stamp is case sensitive. If the device 
mentioned above sent, “xYZ” or “xyZ”, or some other combination of 
lower and upper-case characters, the BASIC Stamp would have ignored it 
because we told it to look for “XYZ” (all capital letters). 
The BS1’s SERIN command is limited to above-mentioned features. If you 
are not using a BS1, please continue reading about the additional features 
below. 
USING SERIN TO WAIT FOR SPECIFIC 
DATA BEFORE PROCESSING
. 
U
SING ASCII CODES AND CASE 
SENSITIVITY
. 
All
 2
This is written with the BS2's Baudmode 
value. Be sure to adjust the value for 
your BASIC Stamp. 
1
1










