MATLAB Language Using serial ports Writing to the serial port


Assuming you created the serial port object s as in this example, then

% Write one byte
fwrite(s, 255);

% Write one 16-bit signed integer
fwrite(s, 32767, 'int16');

% Write an array of unsigned 8-bit integers
fwrite(s,[48 49 50],'uchar');

% Close the serial port