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

ledOnOff.m
% ledOnOff
%
% Page 37
% Chapter 2, Activity 2: ON/OFF CONTROL WITH THE BASIC STAMP
%
% Note that a for loop is used instead of a while loop in this example.
% This is because it's not possible to stop the program by turning off the
% Stamp because MATLAB is the one running the program. We could also try
% having a loop that is terminated by a button press; that would allow for
% an infinite loop that can be stopped.
%
% Run this script by clicking the "Run" button in the toolbar (it looks
% like a green "start" triangle).

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

bs = stamp.BasicStamp('COM4'); %change to your BS2 serial port.

disp('The LED connected to P14 is blinking!');

for i = 1:10
    bs.writePin(14,1);
    pause(.5); % pause argument is measured in ms
    bs.writePin(14,0);
    pause(.5);
end

delete(bs);
    

Contact us