serial.write

serial.write

serial.write

Function

Write data to the opened serial port. Supports String, byte arrays and Bytes.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
dataString/Array/BytesYesNoneString is written as UTF-8; Array elements must be 0 to 255; Bytes writes raw bytes directly.

Return value

TypeDescription
IntReturns the number of bytes written.

Example

Notes

  • An error will be reported when illegal bytes appear in the array.
  • No string conversion is done when writing Bytes.