5: BASIC Stamp Command Reference – SERIN
data you receive is unreadable, it is most likely a baud
rate setting error.
5.
If receiving data from another device that is not a BASIC Stamp,
try to use baud rates of 4800 and below.
a.
Because of additional overhead in the BASIC Stamp, and
the fact that the BASIC Stamp has no hardware receive
buffer for serial communication, received data may
sometimes be missed or garbled.
lowering the baud rate (if possible), adding extra stop bits,
and not using formatters in the SERIN command. Using
simple variables (not arrays) and no formatters will
increase the chance that the BASIC Stamp can receive the
data properly.
6.
Be sure to study the effects of SERIN formatters.
a.
Some formatters have specific requirements that may
cause problems in received data. For example, the DEC
formatter requires a non-decimal-numeric character to
follow the received number before it will allow the BASIC
Stamp to continue. See Appendix C for example input
data and the effects on formatters.
Demo Program (SERIN.bas)
1
' This program waits for the characters "A", "B", "C" and "D" to arrive serially
' (Inverted 2400 baud, N81) on I/O pin 0, followed by a number and a carriage return
' (or some other non-number). It then displays the received number on the DEBUG screen.
'{$STAMP BS1}
SYMBOL Result = W0
Loop:
SERIN 0, N2400, ("ABCD"), #Result
DEBUG #Result, CR
GOTO Loop
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 291
If this occurs, try
'STAMP directive (specifies a BS1)
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?