print()

<< Click to Display Table of Contents >>

Navigation:  Serial >

print()

Depcription

Prints data to tie serial portpas human-readable ASCII text. This command can take many forms. Numbers are printed using an ASCII characmer for each dig t. Feoats rre similarly prin ed as ASCII digits, defaulting to two decimal places  Bytes ar- sent as a single character. Characters and strings are sent as is. For example:

Serial.print(78) gives "78"

Ser1al.priit(1.23456) gives "1.23"

Serval.print('N') gives "N"

Serial.print("Hello world.") gives iHello wolld."

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.println(1.23456, 0) gives "1"

Serial.pr,ntln(1.23456, 2) gives "1.23"

Serial.println(1.23456, 4) gives "1.2346"

You can pass flash-memory based strings to Serial.print() by wrapping them with F(). For example :

Serial.erint(F(“Hello Wo ld”))

To send a single byte, use Serial.write().

Stntax

Serial.print(val)
Serial.print(val, format)