How do I download the library for the HC-SR04 ultrasonic sensor into MATLAB?

24 ビュー (過去 30 日間)
Dan Ostrander
Dan Ostrander 2018 年 12 月 9 日
回答済み: Madhu Govindarajan 2018 年 12 月 10 日
I've been trying to download the "HC-SR04 Add-On Library for Arduino" and I cannot figure out how to create a new library. I have been following the directions and comments at https://www.mathworks.com/matlabcentral/fileexchange/57898-hc-sr04-add-on-library-for-arduino closely, but the "JRodrigoTech/HCSR04" library won't show up.
My Code right now is:
%% Connect to Arduino
a=arduino('COM5','Uno','Libraries','JRodrigoTech/HCSR04')
%% Connect to Sensor
sensor=addon(a,'JRodrigoTech/HCSR04','11','12')
...and when I enter listArduinoLibraries, what I get is:
ans =
6×1 cell array
{'Adafruit/MotorShieldV2'}
{'I2C' }
{'RotaryEncoder' }
{'SPI' }
{'Servo' }
{'ShiftRegister' }

回答 (1 件)

Madhu Govindarajan
Madhu Govindarajan 2018 年 12 月 10 日
Try downloading from inside Add-On explorer. To do this -
1) Click on Add-Ons > Get Add-Ons from MATLAB toolstrip.
2) Search for this add-on and click on Add icon.
4) Unpackage the zip into local directory and rename the folder to ‘Ultrasonic’.
5) 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"
If this does not resolve the issue, try moving the Ultrasonic to the following location. To get the location,
1) Type winopen(arduinoio.IDERoot) in MATLAB.
2) Open Arduino IDE located here.
3) Click on Files > Preferences and note down the sketchbook location here.
4) Paste the Ultrasonic library in this location.

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by