Get one byte of data from serial port
Get one byte of data per sample period from the receive buffer of the specified serial port. For more information, see Use Serial Communications with Arduino Hardware.
The Serial Receive block has two outputs, Data and Status.
When data is available:
The Data block output emits data from the serial receive buffer.
The Status block output emits 1.
When data is not available:
The Data block output emits 255.
The Status block output emits 0.
The Data block output emits uint8 values.
The Status block output emits int values. You can use the Status block output to determine whether a value of 255 emitted by the Data port is data, or an indication that no data was received.
During simulations without the hardware, this block emits zeroes. See Block Produces Zeros or Does Nothing in Simulation
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.
Enter the number of the serial port.
If you set the Target hardware parameter to:
Arduino Mega 2560, enter a port number from 0 to 3.
Arduino Uno, enter 0.
Arduino Nano, enter 0.
Arduino Due, enter a port number from 0 to 3.
You can assign a Serial Transmit block and a Serial Receive block to the same serial port.
Do not assign more than one Serial Receive block 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.
Specify how often this block reads the serial port buffer. Enter a value greater than zero. This value defaults to a sample time of 1 second. The minimum value is 0.000001 second.
Smaller values require the processor to complete the same number of instructions in less time, which can cause task overruns.
Arduino Serial Transmit | Detect and Fix Task Overruns on Arduino Hardware | Install Support for Arduino Hardware | Tune and Monitor Model Running on Arduino Mega 2560 Hardware | Use Serial Communications with Arduino Hardware