/
install_arduino.m
41 lines (34 loc) · 1.54 KB
/
install_arduino.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% This files installs the MATLAB support package for Arduino (ArduinoIO package).
% Copyright 2011 The MathWorks, Inc.
% look for arduino.m
wa=which('arduino.m','-all');
% make sure we are in the right folder and there are no other arduino.m files
if length(wa) < 1,
msg=' Cannot find arduino.m, please run this file from the folder containing arduino.m';
error(msg);
end
if length(wa) > 1,
msg=' There is at least another arduino.m file in the path, the installation will go on but it is strongly suggested to delete any other version before using this one';
warning(msg);
end
% get the main arduino folder
ap=wa{1};ap=ap(1:end-10);
% Add target directories and save the updated path
addpath(fullfile(ap,''));
addpath(fullfile(ap,'simulink',''));
addpath(fullfile(ap,'examples',''));
disp(' Arduino folders added to the path');
result = savepath;
if result==1
nl = char(10);
msg = [' Unable to save updated MATLAB path (<a href="http://www.mathworks.com/support/solutions/en/data/1-9574H9/index.html?solution=1-9574H9">why?</a>)' nl ...
' On Windows, exit MATLAB, right-click on the MATLAB icon, select "Run as administrator", and re-run install_arduino.m' nl ...
' On Linux, exit MATLAB, issue a command like this: sudo chmod 777 usr/local/matlab/R2011a/toolbox/local/pathdef.m' nl ...
' (depending on where MATLAB is installed), and then re open MATLAB and re-run install_arduino.m' nl ...
];
error(msg);
else
disp(' Saved updated MATLAB path');
disp(' ');
end
clear wa ap result nl msg