External Interfaces |
Getting Started with Serial I/O
To get you started with the MATLAB serial port interface, this section provides the following information:
Example: Getting Started
If you have a device connected to the serial port COM1 and configured for a baud rate of 4800, you can execute the following complete example.
s = serial('COM1');
set(s,'BaudRate',4800);
fopen(s);
fprintf(s,'*IDN?')
out = fscanf(s);
fclose(s)
delete(s)
clear s
The *IDN?
command queries the device for identification information, which is returned to out
. If your device does not support this command, or if it is connected to a different serial port, you should modify the above example accordingly.
Selected Bibliography | The Serial Port Session |
© 1994-2005 The MathWorks, Inc.