Interfacing with Parallel Port using MATLAB

By | July 18, 2008

Some applications in MATLAB environment need to communicate with external device either to send or receive signals. MATLAB provides a simple way to handle this task with PC parallel port.

Parallel port IDs and pin number:

Port ID




2 – 9

Eight I/O lines, MSB = pin 9


10 – 13 and 15

Five input lines used for status (output pins)


1, 14, 16 and 17

Five I/O lines used for control (input pins)

MATLAB has digital I/O (DIO) subsystems which are designed to transfer digital values to and from hardware. To send out data, follow the below procedures:

  1. To check the support of your system, type


  1. Create a Digital I/O Object with the digitalio function


  1. Add lines to a Digital I/O Object

addline(dio,0:7,0,’out’); % add the hardware lines 0 until 7 from port 0 to the

% digital object dio

  1. Send data to the lines

putvalue(dio.line(1),1); % send data ‘1’ to line 1

Before executing the program, of course you must have the parallel connection attached to your PC and some LED to indicate that the digital data have been sent.

Have a nice practice controlling your device via parallel port, and please give your comments!

Leave a Reply

Your email address will not be published. Required fields are marked *