Ultrasonic Sensor
R2026bLibraries:
Raspberry Pi Blockset /
Sensors
Simulink Support Package for Arduino Hardware /
Sensors
Description
The Ultrasonic Sensor block outputs the distance between the ultrasonic
sensor connected to the hardware and the nearest object in front of the sensor. The
block outputs the distance as a double-precision value, in meters. If the object is
placed beyond the range of sensor detection, the block outputs 0.
If you simulate a model that contains the Ultrasonic Sensor block without connecting the hardware, the block outputs zeros. For more information, see Block Produces Zeros or Does Nothing in Simulation (Simulink).
Note
To generate C/C++ code for this block, you must have an Embedded Coder® license.
Ports
Output
Parameters
Programmatic Use: Add Block
To add the block programmatically, use the add_block function with one of these library block paths as the source.
"raspberrypisensorlib/Ultrasonic Sensor"
"arduinosensorlib/Ultrasonic Sensor"
Example: add_block("raspberrypisensorlib/Ultrasonic Sensor","myModel/myBlock",MakeNameUnique="on")
More About
Extended Capabilities
Version History
Introduced in R2022b



