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

ledButton.m
% ledButton
%
% Page 70
% Chapter 3, Activity 3: PUSHBUTTON CONTROL OF AN LED CIRCUIT
%
% Note the more complex while loop. This is because a true infinite loop
% would be impossible to escape from. Instead, this loop "times out" if a
% button is not pressed for a long enough time (about 100*.1s, or 10
% seconds).

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

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

stop = 100;

while stop ~= 0
    if bs.readPin(3)
        bs.writePin(14,1);
        stop = 100;
    else
        bs.writePin(14,0);
        stop = stop - 1;
        pause(.1);
    end
end

delete(bs);

Contact us