You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

30 lines
704 B

function [state] = CliffFrontRightSensorRoomba(serPort);
%[state] = CliffFrontRightSensorRoomba(serPort)
% Specifies the state of the Cliff Front Right sensor
% Either triggered or not triggered
% By; Joel Esposito, US Naval Academy, 2011
%Initialize preliminary return values
state = nan;
try
%Flush Buffer
N = serPort.BytesAvailable();
while(N~=0)
fread(serPort,N);
N = serPort.BytesAvailable();
end
warning off
global td
fwrite(serPort, [142]); fwrite(serPort,11);
CliffFrntRght = dec2bin(fread(serPort, 1));
state = bin2dec(CliffFrntRght(end));
pause(td)
catch
disp('WARNING: function did not terminate correctly. Output may be unreliable.')
end