BASIC stamp manual v2.2
SERIN - BASIC Stamp Command Reference
Page 400 • BASIC Stamp Syntax and Reference Manual 2.2 • www.parallax.com
2) Serial input: 123 (with no characters following it)
Result: The BASIC Stamp halts at the SERIN command. It
recognizes the characters “1”, “2” and “3” as the number one
hundred twenty three, but since no characters follow the “3”, it
waits continuously, since there’s no way to tell whether 123 is the
entire number or not.
3) Serial input: 123 (followed by a space character)
Result: Similar to example 2, above, except once the space
character is received, the BASIC Stamp knows the entire number
is 123, and stores this value in serData. The SERIN command then
ends, allowing the next line of code, if any, to run.
4) Serial input: 123A
Result: Same as example 3, above. The “A” character, just like the
space character, is the first non-decimal text after the number 123,
indicating to the BASIC Stamp that it has received the entire
number.
5) Serial input: ABCD123EFGH
Result: Similar to examples 3 and 4 above. The characters
“ABCD” are ignored (since they’re not decimal text), the
characters “123” are evaluated to be the number 123 and the
following character, “E”, indicates to the BASIC Stamp that it has
received the entire number.
For examples of all formatters and how they process incoming data, see
Appendix C.
Of course, as with all numbers in the BASIC Stamp, the final result is
limited to 16 bits (up to the number 65535). If a number larger than this is
received by the decimal formatter, the end result will look strange because
the result rolled-over the maximum 16-bit value.
The BS1 is limited to the decimal formatter shown above, however all the
BS2 models have many more conversion formatters available for the
SERIN command. If not using a BS1, see the “Additional Conversion
Formatters” section below for more information.
WATCH OUT FOR ROLLOVER ERRORS.