ultrasonic
Connection to ultrasonic sensor on Arduino hardware
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
This object represents a connection to an ultrasonic sensor connected to the Arduino® hardware. To measure the distance to an object with the ultrasonic sensor, use this object with the functions listed in Object Functions.
Creation
Syntax
Description
creates an ultrasonic sensor connection for a three-pin sensor connected to the specified
trigger pin on the Arduino hardware.ultrasonicObj
= ultrasonic(arduinoObj
,triggerPin
)
creates an ultrasonic sensor connection for a four-pin sensor connected to the specified
pins on the Arduino hardware.ultrasonicObj
= ultrasonic(arduinoObj
,triggerPin
,echoPin
)
creates an ultrasonic sensor connection for a four-pin sensor with the specified pins on
Arduino hardware. For a three-pin sensor,the echo pin is the same as the trigger
pin.ultrasonicObj
= ultrasonic(arduinoObj
,triggerPin
,echoPin
,Name,Value
)
Input Arguments
Object Functions
readDistance | Distance to object in front of ultrasonic sensor |
readEchoTime | Read echo time of ultrasound waves |
Examples
Version History
Introduced in R2019a