SEROUT - BASIC Stamp Command Reference
Page 298
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
SEROUT 1, N2400, ( 65 )
--or--
SEROUT 1, 16780, [ 65 ]
Here, SEROUT will transmit a byte equal to 65 (the ASCII value of the
character "A") through pin 1. If the BASIC Stamp were connected to a PC
running a terminal program (set to the same baud rate) the character "A"
would appear on the screen (see the ASCII character chart in the
appendix).
What if you really wanted the value 65 to appear on the screen? If you
remember from the discussion in the SERIN command, "It is up to the
receiving side (in serial communication) to interpret the values…" In this
case, the PC is interpreting the byte-sized value to be the ASCII code for
the character "A". Unless you're also writing the software for the PC, you
can't change how the PC interprets the incoming serial data, so to solve
this problem, the data needs to be translated before it is sent.
The SEROUT command provides a formatter, called the decimal
formatter, which will translate the value 65 to two ASCII codes for the
characters "6" and "5" and then transmit them. Look at the following code:
SEROUT 1, N2400, ( #65 )
--or--
SEROUT 1, 16780, [ DEC 65 ]
Notice the decimal formatter in the SEROUT command. It is the “#” (for
the BS1) or “DEC” (for the other BASIC Stamps) that appears just to the
left of the number 65. This tells SEROUT to convert the number into
separate ASCII characters which represent the value in decimal form. If
the value 65 in the code were changed to 123, the SEROUT command
would send three bytes (49, 50 and 51) corresponding to the characters "1",
"2" and "3".
The BS2, BS2e, BS2sx and BS2p have many more conversion formatters
available for the SEROUT command. See the “Additional Conversion
Formatters” section below for more information.
A
SIMPLE NUMERIC CONVERSION
;
DECIMAL TO
ASCII
NUMERIC TEXT
.
1
1
2
e
2
sx
2
p
2
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.
This is written with the BS2's
BaudMode value. Be sure to adjust
the value for your BASIC Stamp.
2
e
2
sx
2
p
2
Содержание BASIC Stamp 2e
Страница 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...