function [out] = needle_close
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);

%following is for solenoid 1 off, all others off (1=on, 0-off)
num = bin2dec('00000000');
fwrite(p, [9 0 num], 'uint8');
R1 = fread(p,1,'uint8');    % 1 - success, 0 - failure
R2 = fread(p,1,'uint8');    % doesn't matter (you'll get 0)
R3 = fread(p,1,'uint8');    % doesn't matter (you'll get 0)

fclose(p);
out = R1;