Legacy HC-SR04 Add-On Library for Arduino

Interface with HC-SR04 ultrasonic sensors connected to Arduino hardware in MATLAB.
19,6K téléchargements
Mise à jour 8 mai 2019

Afficher la licence

Note de l’éditeur :

For R2019a and later, this functionality is included with the MATLAB Support Package for Arduino Hardware. Users of MATLAB R2019a and later versions should not use this add-on library.

This add-on library is only for use in MATLAB R2016a through R2018b.

This add-on is supported for MATLAB R2016a - R2018b. For R2019a and later, this functionality is included with the support package.

This add-on extends MATLAB Support Package for Arduino Hardware to read distance measurements from HC-SR04 ultrasonic sensors. With this add-on, you can read distance in meters or travel time in seconds to calculate the distance more precisely.

Sample usage:
-------------------
% Create arduino object with the add-on library
a = arduino('COM38', 'Uno', 'Libraries', 'JRodrigoTech/HCSR04');
% Create ultrasonic object
sensor = addon(a, 'JRodrigoTech/HCSR04', 'D12', 'D13');
% Obtain sensed distance
dist = readDistance(sensor);

It includes documentation and an example that demonstrates the use with HC-SR04 sensor to get sensed distance.

Important: Before using this add-on library in MATLAB, you need to install the Ultrasonic Arduino library. Here are the instructions:
1. Download the zip file from https://github.com/JRodrigoTech/Ultrasonic-HC-SR04/archive/master.zip
2. Unpackage the zip into local directory and rename the folder to ‘Ultrasonic’.
3. Move the ‘Ultrasonic’ folder into the "libraries" folder inside your Arduino sketchbook folder:
On Windows, the default path is "My Documents\Arduino\libraries\"
On Mac, the default path is "~/Documents/Arduino/libraries/"
On Linux, the default path is "/home/<username>/Arduino/libraries"

Troubleshooting tips:
1. After installing this add-on library and the required Arduino library, type "listArduinoLibraries" in MATLAB to see if the add-on is properly installed.
2. Wire up the Arduino board and the add-on device properly before creating the object to avoid a connection error in MATLAB.
3. Refer to the documentation for details on usage and syntax. It can be found under Supplemental Software in the product documentation.

Feel free to contact the MATLAB Hardware Team if you have questions about this add-on library:
http://www.mathworks.com/matlabcentral/profile/contact/4922363-mathworks-matlab-hardware-team

Citation pour cette source

MathWorks MATLAB Hardware Team (2024). Legacy HC-SR04 Add-On Library for Arduino (https://www.mathworks.com/matlabcentral/fileexchange/57898-legacy-hc-sr04-add-on-library-for-arduino), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2016a
Compatible avec les versions R2016a à R2018b
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

+arduinoioaddons/+JRodrigoTech

Version Publié le Notes de version
1.2.1

Added Legacy to title

1.2

Updated description and release compatibility to specify that the library is only supported for releases through R2018b.

1.1

Added license addendum and updated MathWorks http references to https
Updated description

1.0.0.0