Code covered by the BSD License  

Highlights from
MATLAB Support Package for Parallax BASIC Stamp

image thumbnail

MATLAB Support Package for Parallax BASIC Stamp

by

 

25 Jul 2011 (Updated )

MATLAB library for communicating with a BASIC Stamp 2 and Board of Education (BoE) kit

rotStripchart()
% rotStripchart
%
% NOTE: This function uses EasyGUI, a tool for easily making graphical
% interfaces in MATLAB. Before running this function, <a href="http://www.mathworks.com/matlabcentral/fileexchange/22936">download EasyGUI</a> and
% install it.
%
% This function does not have a direct analog in the book. Use the same
% hardware setup as measureRot.
%
% This function measures the resistance of the potentiometer every 100ms
% (or so) and plots the resulting time to a stripchart that updates in
% realtime. This also serves as an example of how MATLAB can be used to
% collect and analyze data from the BS2; the same code that plots the time
% data could easily have put it in a vector for analysis using MATLAB's
% extensive toolset.

%   MATLAB Support Package for BASIC Stamp
%   Version 1.0
%   Copyright 2011 The MathWorks, Inc.

function rotStripchart()

if ~exist('gui.stripchart','class')
    error('EasyGUI not found. Please install EasyGUI and try again.');
end

bs = stamp.BasicStamp('COM4'); %replace with your BS2 serial port

chart = gui.stripchart(gca,101);

for i = 1:100
    bs.writePin(7,1);
    pause(.1);
    time = bs.getRCTime(7,1);
    chart.update(time);
end

delete(bs);
delete(chart);

end

Contact us