Code covered by the MathWorks Limited License

Highlights from
Sparkfun RedBot Block Library

image thumbnail

Sparkfun RedBot Block Library

by

 

22 Oct 2013 (Updated )

A library of blocks to get started with the Sparkfun RedBot Kit.

install_sparkfunRedBotBlockLib
function install_sparkfunRedBotBlockLib
% Attempts to install the Sparkfun RedBot block library

% Copyright 2013 The MathWorks, Inc.


if ~isempty(which('sparkfun_redbot_block_lib','-all'))
  disp('The Sparkfun RedBot Block Library is already installed');
  return; % already installed
end

if ~exist('.\sparkfun_redbot_block_lib.zip') %#ok<EXIST>
    error('The sparkfun_redbot_block_lib zip file was not found in the current folder');
end

% Find the root installation directory of Arduino Support Package and
% install the library in that folder

arduinopath = which('arduinolib','-all');

if isempty(arduinopath)
    error('The Simulink Support Package for Arduino has not been installed. Please install the Support Packaget first');
end

arduinopath = arduinopath{1};
installOutputPath = arduinopath(1:strfind(arduinopath,'arduino\blocks\arduinolib.slx')-1);

try
    unzip('.\sparkfun_redbot_block_lib.zip',installOutputPath);
catch err
    error(['Error while unzipping!, Manually unzip the file to:' installOutputPath ' and add the new folder to the path']);
end

libraryPath = [installOutputPath 'sparkfun_redbot_block_lib\'];
addpath(libraryPath);
savepath;
rehash toolboxcache;
disp('Library was installed successfully!');

Contact us