Skip to content

Wrap examples properly in Serial.print() #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions Language/Functions/Communication/Serial/print.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@ title: Serial.print()
=== Description
Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is. For example-

* `Serial.print(78) gives "78"` +
* `Serial.print(1.23456) gives "1.23"` +
* `Serial.print('N') gives "N"` +
* `Serial.print("Hello world.") gives "Hello world."`
* `Serial.print(78)` gives "78" +
* `Serial.print(1.23456)` gives "1.23" +
* `Serial.print('N')` gives "N" +
* `Serial.print("Hello world.")` gives "Hello world."


An optional second parameter specifies the base (format) to use; permitted values are `BIN(binary, or base 2)`, `OCT(octal, or base 8)`, `DEC(decimal, or base 10)`, `HEX(hexadecimal, or base 16)`. For floating point numbers, this parameter specifies the number of decimal places to use. For example-

* `Serial.print(78, BIN) gives "1001110"` +
* `Serial.print(78, OCT) gives "116"` +
* `Serial.print(78, DEC) gives "78"` +
* `Serial.print(78, HEX) gives "4E"` +
* `Serial.print(1.23456, 0) gives "1"` +
* `Serial.print(1.23456, 2) gives "1.23"` +
* `Serial.print(1.23456, 4) gives "1.2346"`
* `Serial.print(78, BIN)` gives "1001110" +
* `Serial.print(78, OCT)` gives "116" +
* `Serial.print(78, DEC)` gives "78" +
* `Serial.print(78, HEX)` gives "4E" +
* `Serial.print(1.23456, 0)` gives "1" +
* `Serial.print(1.23456, 2)` gives "1.23" +
* `Serial.print(1.23456, 4)` gives "1.2346"

You can pass flash-memory based strings to Serial.print() by wrapping them with link:../../../../variables/utilities/progmem[F()]. For example:

Expand Down