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 CenterFile Exchange에서 Instrument Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by