Serial Transmit
Send buffered data to the specified serial port
Library
Simulink Support Package for Arduino® Hardware
Description
Send buffered data to the specified serial port. For more information, see Use Serial Communications with Arduino Hardware.
The Arduino Uno hardware has one
serial port device, serial port 0, connected to the digital pins marked
TX 0
and RX 0
. If you set the
Port number parameter to 0
, this
block transmits over the digital pin marked TX 0
.
The block input accepts vector or scalar data of datatypes, uint8, int8, uint16, int16, uint32, int32, double, single, or boolean.
During simulations without the hardware, this block does nothing.
If you use this block in models with the Standard Servo Read, Standard Servo Write, and Continuous Servo Write blocks, use longer sample times to avoid overruns.
Warning
Do not connect the serial port pins to an RS-232 serial interface, such as the DE-9M connector on a computer, without limiting the voltage. The RS-232 standard allows higher voltages that can damage your hardware. For details, read the documentation for your Arduino hardware.
Note
The double datatype occupies 8 bytes (64 bit) on the Arduino Due board and it occupies 4 bytes (32 bit) on the other Arduino boards.
Parameters
- Port Number
Enter the number of the serial port.
Click View pin map to open the Arduino Pin Mapping table.
To know about the fixed ports and the allocated pins for the block, see Pin Mapping for Arduino Timer Independent Blocks.
You can assign a Serial Transmit block and a Serial Receive block to the same serial port.
Do not assign multiple Serial Transmit blocks to the same serial port.
Do not assign the pin numbers used by the serial port to other blocks within the model.
Serial port 0 is connected to the USB port through a converter. Do not use both serial port 0 and the USB port at the same time. For example, do not use serial port 0 if you intend to use External mode, because External mode requires the USB port.
- Send mode
Select the mode in which you want to send the data.
Select
write
option to write the raw data to the serial port.Select
print
option to print the formatted data to the serial port as ASCII text.Select
println
option to print the formatted data to the serial port as ASCII text followed by a carriage return character '\r'( ASCII 13) and a newline character '\n'(ASCII 10).- Label
Enter the label/header text for the data that you want to print.
- Format
Select the format in which you want to print the data. You can select the
Decimal
,Hexadecimal
,Binary
, or theOctal
option for data to print.Decimal
is the default option.- Precision
Enter the precision value for the Decimal data format. 2 is the default option.
This parameter is available only when you select
Decimal
option in Format parameter.
See Also
Serial Receive | Install Support for Arduino Hardware | Use Serial Communications with Arduino Hardware | Pin Mapping for Arduino Timer Independent Blocks