Code covered by the BSD License  

Highlights from
MATLAB Support Package for Velleman K8055/VM110 Experiment Board

MATLAB Support Package for Velleman K8055/VM110 Experiment Board

by

 

MATLAB library for communicating with a Velleman K8055/VM110 USB Experiment Interface Board

LEDCursor.m
% Script that controls "moves" a light up and down the digital output LEDs
% using digital inputs 1 and 2. Input 1 moves it "up" (ie. high numbered
% outputs), and input 2 moves it "down". The light starts below position 0,
% so press up (1) to see it. End the script with digital output 5.

%   Copyright 2011 The MathWorks, Inc.

board = vellboard.ExperimentBoard; %setup board and counters
board.resetCounter(1);
board.resetCounter(2);
board.writeDigitalAll(zeros(1,8));

currentled = 0;

while(~board.readDigital(5)) %while button 5 isn't pressed
    newled = board.readCounter(1) - board.readCounter(2); %get new position
    if newled < 0 %bring it in range
        newled = 0;
    elseif newled > 9;
        newled = 9;
    end
    
    if currentled ~= newled %change leds as necessary
        if currentled>0 && currentled<9
            board.writeDigital(currentled,0);
        end
        if newled>0 && newled<9;
            board.writeDigital(newled,1);
        end
    end
    
    currentled = newled; %and close the loop
    drawnow;
end

board.writeDigitalAll(zeros(1,8)); %clear digital outputs
delete(board);

Contact us