Specifications

BASIC Stamp II
Parallax, Inc. • BASIC Stamp Programming Manual 1.8 • Page 323
2
myText var byte(10) ' An array to hold the string.
myText(0) = "H":myText(1) = "E" ' Store "HELLO" in first 5 cells...
myText(2) = "L":myText(3) = "L"
myText(4) = "0":myText(9) = 5 ' Put length (5) in last cell.
Serout 1,16468,[STR myText\myText(9)] ' Send "HELLO"
Note that Serout’s string capabilities work only with strings in RAM,
not EEPROM. To send a string from EEPROM you must either (1) Read
it byte-by-byte into an array then output it using one of the STR modi-
fiers, or (2) Read and output one byte at a time. Since either approach
requires Reading individual bytes, method (2) would be simpler. The
demo program for the Read instruction gives an example; making it
work with Serout requires changing Debug...
debug char ' Show character on screen.
...to Serout, as in this example:
Serout 1,16468,[char] ' Send the character.
If you have just a few EEPROM strings and don’t need to manipulate
them at runtime, the simplest method of all is to use separate Serouts
containing literal text, as shown in the previous section.
Using the Pacing Option and a Serout/Debug Trick
Serout allows you to pace your serial transmission by inserting a time
delay of 1 to 65535 ms between bytes. Put the pacing value between
the baudmode and the outputData list, like so:
Serout 1,16468,1000,["Slowly"] ' 1-sec delay between characters.
Suppose you want to preview the effect of that 1-second pacing with-
out the trouble of booting terminal software and wiring a connector.
You can use the BS2 Debug window as a receive-only terminal. Tell
Serout to send the data through pin 16 (the programming connector)
at 9600 baud:
Debug cls ' Open a cleared Debug window.
Serout 16,84,1000,["Slowly"] '
Serout to Debug screen.
Controlling Data Flow
In all of the examples above, Serout sent the specified data without