Thread: RB-730 with matlab View Single Post
akr
Junior Member
 
Join Date: Apr 2008
akr is on a distinguished road Posts: 4
Some Progress, Posted April 4th, 2008 #2
Hi Folks,

I was able to make some progress but still having trouble on keeping the horizontal bar growing as the subject holds down a key. I've posted the modified code below. Basically, instead of calling cedrusxid again and again, I only call the fopen and fclose once. This makes for a faster response to the bar growth. Any help is greatly appreciated.

Thanks,

Anil.

function [ output_args ] = test
%TEST Summary of this function goes here
% Detailed explanation goes here

maxscale = 120;
tension = 1;
barh([tension maxscale]);
drawnow;
y = 0;

s1 = serial('COM3', 'BaudRate', 115200,'DataBits', 8, 'StopBits', 1, 'FlowControl', 'none', 'Parity', 'none', 'Terminator', 'CR', 'Timeout', 400, 'InputBufferSize', 16000);

fopen(s1);

while y~=48
response = fread(s1,6);
button = (response(2));
y = button;

if y == 80
tension = tension + 5;
end

if y == 112
tension = tension - 5;
end

barh([tension maxscale]);
drawnow;
end

fclose(s1);

end
Reply With Quote