SERIN - BASIC Stamp Command Reference
Page 278
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
If you’re communicating with existing software or hardware, its speed(s)
and mode(s) will determine your choice of baud rate and mode. In
general, 7-bit/even-parity (7E) mode is used for text, and 8-bit/no-parity
(8N) for byte-oriented data. Note: the most common mode is
8-bit/no-parity, even when the data transmitted is just text. Most devices
that use a 7-bit data mode do so in order to take advantage of the parity
feature. Parity can detect some communication errors, but to use it you
lose one data bit. This means that incoming data bytes transferred in 7E
(even-parity) mode can only represent values from 0 to 127, rather than
the 0 to 255 of 8N (no-parity) mode.
Usually a device requires only 1 stop bit per byte. Occasionally, however,
you may find a device that requires 2 or more stop bits. Since a stop bit is
really just a delay between transmitted bytes (leaving the line in a resting
state) the BASIC Stamp can receive transmissions with multiple stop bits
per byte without any trouble. In fact, sometimes it is desirable to have
multiple stop bits (see the “SERIN Troubleshooting” section, below, for
more information).
The example below will receive a single byte through I/O pin 1 at 2400
baud, 8N1, inverted:
Symbol SerData = B0
SERIN 1, N2400, SerData
--or--
SerData VAR BYTE
SERIN 1, 16780, [SerData]
Here, SERIN will wait for and receive a single byte of data through pin 1
and store it in the variable SerData. If the BASIC Stamp were connected to
a PC running a terminal program (set to the same baud rate) and the user
pressed the "A" key on the keyboard, after the SERIN command executed,
the variable SerData would contain 65, the ASCII code for the letter "A"
(see the ASCII character chart in the appendix).
What would happen if, using the example above, the user pressed the "1"
key? The result would be that SerData would contain the value 49 (the
ASCII code for the character "1"). This is a critical point to remember:
every time you press a character on the keyboard, the computer receives
the ASCII value of that character. It is up to the receiving side (in serial
C
HOOSING THE PROPER BAUD MODE
.
A
SIMPLE FORM OF
SERIN.
A
SIMPLE NUMERIC CONVERSION
;
ASCII
TEXT TO DECIMAL
.
1
2
e
2
sx
2
p
2
This is written with the BS2's
BaudMode value. Be sure to adjust
the value for your BASIC Stamp.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...