This page documents the Print command and its options.
The simplest form of the print command causes bitlash to print out a bunch of numeric values separated by spaces, followed by a newline:
> print 1, 2+2, 1<<3 1 4 8 >
The print command can print string constants as well as numeric expressions, as you may recall from the Hello World example:
> print "Hello, world!", 123 Hello, world! 123
To suppress the blank and automatic end of line, print a single value followed by the comma, like this:
> print "Time:", // Prints Time: with no trailing blank or newline
The rules for special characters are similar to C. See Language for details on constructing string constants with arbitrary ascii characters.
You can specify a modifier to produce several different output types by appending ”:spec” to any expression in a print statement. Perhaps an example is quickest:
> print 33, 33:x, 33:b, 33:y, 33:* 33 21 100001 ! *********************************
Here is a mapping to the Arduino equivalents for hex, binary, and raw byte output:
| to print: | Bitlash | Arduino |
|---|---|---|
| print hex | print value:x | Serial.print(value, HEX) |
| send ascii byte value | print value:y | Serial.print(value, BYTE) |
| print binary | print value:b | Serial.print(value, BIN) |
You can print a bar of N '*' characters using the :* format specifier, as shown in the example above. Any single-byte symbol will work (+-*/<>%:). Here's a cheap, low-res oscilloscope on pin A3 with adjustable temporal resolution:
> while 1: print map(a3,0,1024,10,50):*; delay(5)
Bitlash includes a software serial output capability which supports transmitting on any available output pin at a user-specified baud rate. This makes it straightforward to integrate additional serial devices with an Arduino.
You send output to an alternate output pin using the “print #n:” construct, where “n” is the Arduino pin number designator for the desired the output pin:
> print #6:"EMERGENCY DESTRUCT SEQUENCE ALPHA CONFIRMED"
By default bitlash will send output at 9600 baud. If you require a different baud rate use the baud function:
> baud(4,4800) // set baud on pin 4 to 4800 > print #4:"ATZ" // send some stuff on pin 4
Note: print #n: is blocking: background macros will pause while output is being printed.
Here is an example combining the use of printing to an arbitrary pin, printing special characters, and (importantly!) suppressing the inter-item and inter-line spacing that bitlash would normally generate. Assume the serial LCD is on pin 4 and that all pin setup and baud rate initialization has been performed. Then this macro will clear the screen:
cls:="print #4:\"\xfe\x01\","