function [temperature] = microaqueduct

temperature = 0;
PORT = 'COM4';
b = PORT;
p = serial(b); % creating a serial port object for input port 'b'
set(p,'BaudRate',9600);
set(p,'Terminator','CR');
set(p,'Timeout',100);
fopen (p);

%fwrite(h,5,'uint8');
%fwrite(h,0,'uint8');
%fwrite(h,0,'uint8');

fwrite(p,[5 0 0],'uint8');

R1 = fread(p,1,'uint8');    % 1 - success, 0 - failure

if(R1 == 0)
    disp('ERROR READING BYTE 1 FROM IO BOX IN COMMAND microaqueduct()');
end

R2 = fread(p,1,'uint8');    % upper 4 bits
R3 = fread(p,1,'uint8');    % lower 8 bits

voltage = 0.01*round(1000*((256*R2 + R3)/4096))  % a voltage between 0-10V

temperature = voltage * 10;

fclose(p);


