function R = getArduinoLibraryDir(varargin)
% getArduinoLibraryDir
% Copyright 2015 - 2016 The MathWorks, Inc.
    
    userData = getenv('USERPROFILE');
    appData = fullfile(userData, 'AppData', 'Roaming', 'Arduino15', 'preferences.txt');
    fc = fileread(appData);
    tok = regexp(fc, 'sketchbook.path=([^\r\n]+)', 'tokens', 'once');
    R = fullfile(tok{1}, 'libraries');
    if nargin > 0
        R = fullfile(R, varargin{:});
    end
    
end