Delicious  Bookmark this on Delicious    Recommend to StumbleUpon

Using a PC's parallel port for more than printers... with old systems and software

This material is about the parallel port on MS-DOS / Windows computers. It confines itself to such things on old machines, using old software. (Pre-Windows XP).

See my main parallel port help page if you are working with a newer system.

PLEASE NOTE: You CAN damage your computer if you make ill-advised connections to it.
Any use you make of anything you find here must be AT YOUR OWN RISK


Here you will find information about......

Before we get to the parallel port stuff, an ad from your sponsor...

If you are going to use this page, you are probably not a computing novice. Ever set up a web server? It isn't hard! If you have an always- on broadband connection, FarWatch may be of interest. I have written pages for you explaining how to use an old Win98 box (or better) to give yourself a way to monitor the premises the old Win98 box is at from anywhere on the internet. Nothing to buy! And if you connect something to that PC via it's parallel port, you can "see" the state of the inputs to the parallel port from afar, too.

Don't let the warning above worry you too much... I want to stress that there is a lot of fun to be had with electronics projects. Find yourself an 'antique' PC. If you can't rescue one from a dusty corner, you can buy one for almost nothing. You can use the same monitor as you use on your main machine. If you wreck the antique, it hasn't cost you much! (I got one, with monitor, off a sidewalk once!)

I have a third generation inexpensive 'protect the computer' circuit. You interpose it between your PC and the home-made stuff you are attaching to the parallel port.

Quick guide... extended explanations appear further down the page


For a simple program to turn bits on or off just by clicking a button, go to my shareware site. There are free programs there... some for toggling or reading bits, including one for electronic time measurement via the parallel port, or via a joystick's "fire" buttons. There are some for Windows 98, which may even work on earlier systems, in addition to versions for later systems.

To send 123 to the parallel port....

(There are notes below about obtaining Delphi)

Once upon a time, sending 123 to the parallel port (or reading from the input bits there) was easy. But that ended for Windows when Win98 arrived. See my other parallel port page if you aren't working with an antique.

If you are determined to send 123 to the parallel port on an older machine..... ----
In Delphi 1 or Turbo Pascal:
(The code above won't work in Delphi 2 or with Win 9x)

In Delphi 2 (and probably higher), for Win95 and 98 (but not NT), add the following procedure....
    procedure PortOut(IOport:word; Value:byte); assembler;
      xchg ax,dx
      out dx,al
.... and then you can send 123 to the parallel port with
The code above won't work in Delphi 1 or with Win 3x, or NT, or 2000, or XP. Remember that there's a better way... see using inpout32.dll, above.

A newsgroup post said that in QuickBasic you do the following
    Out &h378,123
The &h378 is just another way of saying 888. The &H part says "what follows is written in hexadecimal (aka "hex"). Hex 378 is the same as decimal (our "normal") 888. It's like the "difference" between "12", "twelve" and "dozen".

(How to access the other lines of the parallel port is covered further down the page.)


See my main parallel port page for most of the hardware information- pin outs, etc. Inputs: If you read address 889, you can discover the state of 5 pins. They determine the state of bits 3-7 of 889. bTmp:=port[889] is the 'raw' Pascal you need. Obviously, you do clever things with the result of that. The bits are mapped and named as follows:
Bit Pin Name
3   15   Error
4   13   Select In
5   12   Paper Empty
6   10   Acknowledge
7   11   Busy
(A trap for the unwary... 'Busy' is inverted 'just inside' the computer. Thus if you apply a '1' to all of the pins, you'll see 01111xxx when you read 889! Isn't computing fun?)

Before turning to more generally useful things, I might as well finish off the other pins....

Write to 890 to set the state of the following pins:
Bit Pin Name
0    1   Strobe
1   14   Auto Linefeed
2   16   Initialize
3   17   Select Out

The rest of this page is rough.... but ready.

The layout is a mess (sorry), and there's more editing to do (you're welcome) but there's a lot of good info and links below and on the linked pages....

The following freeware runs in DOS and controls and monitors a parallel port (LPT1, LPT2, LPTM).

The 8 input and 8 output bits appear as large bright/ dim rectangles on the screen so you can see bits across the classroom. The input bits are all 'fixed' so that the two ports appear as one 8-bit input port using pins 10 through 17. F keys can be used to turn output bits on or off or blink them. I have a lot more to this but it'll be a while before I get the other parts of the package cleaned up (I have a graphical state-table sequencer etc. for sequencing and control). There is more on this at Terry King's site. With a few LEDs and switches, you're set to have some fun. You can go a lot further, if you want to add other sensors. (More on sensors at Sheepdog's Sensing and Control site.)

Freeware from Terry King, Vermont, USA. Used with school kids, aged 10-13.

The good people at have wrestled with the problems of using old apps with the post Win98 operating systems. See in particular their "Port Talk". used to have good tutorials providing you with do-it-yourself-style articles. These articles showed you how to interface devices to your PC. Devices like motors, relays, A/D and D/A converters, LCDs, keypads etc. The tutorials were complete with schematic wiring diagrams, parts lists, parts suppliers, etc. Site was faulty over several days at 2/2010.

If any reader knows how to determine the memory address used in a DOS or Windows 3.1 machine for the LPT port, if it isn't 888, I'd be glad to know. I'd even welcome information on addresses which might be right. (I'm particularly interested in driving the pins of an IBM Model 755, aka 9545.)

Remember 'the' PC is not always made exactly the same way... and, especially with old machines, a bit may be damaged or not implemented. Experiment! Be sure to test things as you go along, 'bottom up.'

I have driven LEDs directly from the parallel port in my machine.... but I wouldn't assume that every machine has sufficiently strong outputs. AND BE SURE TO INCLUDE a resistor in series with the LED whenever you use an LED, be it with the parallel port, or otherwise.

(For the barely-started: Do be careful not to connect more than 5v to any input, and NOT to connect 0 or 5v directly to any output. There should be significant resistance between an output and either 0v or 5v, e.g. the resistor mentioned in my simple experiment with the LED, above.)

If you are ensconced in the brave new world of Windows, you're not supposed (gasp, horror) to access ports directly. There are good reasons for the rule... but there are also times to break it!

With the old Borland Turbo Pascal, making the pins of LPT1 all 5v was as simple as

In Borland's superb Delphi, version 1, you could still do

I'm told that was dropped in later versions of Delphi, BUT... fear not!...

Version 1 has been given away many times on cover discs of magazines like the now extinct, but many years excellent UK magazine Personal Computer World. It is also bundled with later versions of Delphi. It is a superb tool for creating Windows applications. Version 1 is for Windows 3.1, BUT NB: programs written with version 1 WILL run under Windows 95 (to my personal knowledge, including the program below), and I am confident that they would also run under 98. You would not have access to long filenames. (Big deal!.. you can use the DOS alias names.) Version 7 has also appeared on cover discs.

Just to check that the parallel port pins could be controlled with a Delphi program, I wrote the following tiny program. The form it relates to has only a button on it. When the program starts, the button is marked '255' and all of the data lines are at 5v. Clicking the button toggles the system between that state and one in which the button is marked '0' and all the data lines are at 0v. The core of the program's code is as follows:
procedure TForm1.FormCreate(Sender: TObject);

procedure TForm1.Button1Click(Sender: TObject);
if button1.caption='255' then begin
      (*Makes outputs 0v*)
     end(*no ; here*)
  else begin
      (*Makes outputs 5v*)
Here is a version which will compile in Delphi 2, for Windows 95 and higher. The form has a Timer on it. The timer's interval property is set to 2000. The only other thing the form needs is a label called Label1. Below is EVERYTHING you need from 'implementation' through to the final 'end.'

{$R *.DFM}
{$R+} {nothing to do with previous $R}

(*The Delphi 2 on-line help has an entry for Mem[<seg>:<offset>], but
  the compiler does not seem to recognize it, not does it appear in the
  Reference Library Guide. Various postings in usergroups
  seem to say that Win95 will not let programs access physical memory.
  There was also an entry for something called ExtEscape which looked
  promising for sending something to the port, but I haven't explored
  that yet, and it didn't appear in Reference Library Guide either.

 Peter Below (TeamB) provided the following port access routines
 in a newsgroup post. He said push and pop were not needed, that
 they were in fact bad ideas. He pointed out that the function uses
 the normal Delphi 2/3 register calling convention and thus will get
 the first parameter (e.g. IOPort) in eax, the second in edx.

 In addition, he said...
 This will not work on NT; it works on Win9x only because the OS has a
 generic port driver. For NT you need to install such a driver first.
 Here are a few URLs worth checking:
    DriverX        Tinyport (NT only)

    procedure PortOut(IOport:word; Value:byte); assembler;
      xchg ax,dx
      out dx,al

(*More, similar, routines from Peter Blow. They are not needed
  in this simple demo program...

    function PortIn(IOport:word):byte; assembler;
      mov dx,ax
      in al,dx

    function PortInW(IOport:word):word; assembler;
      mov dx,ax
      in ax,dx

    procedure PortOutW(IOport:word; Value:word); assembler;
      xchg ax,dx
      out dx,ax

End of material from Peter Blow*)

procedure TForm1.Timer1Timer(Sender: TObject);
if bPoke<>0 then begin
 end(*no ; here*)
 else begin


In a newsgroup, I saw: "the TDLPort IO 'wrapper' can be installed as a Delphi component. This allows IO under Win95/98 and (using a different file) Win NT. I know the latter normally blocks attempts to Write to/Read from specific addresses but the DLL (legally) get around the problem. I'm hoping that the Win95/98 version will do the same rather than just re-duplicate inpout32. It comes with a nice manual and is FREE!

Even though there was a lysdexic error in the above, Google found for me an article for me at containing....
Name: TDLPortIO 1.3 Date: 12/7/99
Environment: Delphi 3.0, Delphi 4.0, C++ Builder 3.0, C++ Builder 4.0 Download
Type: Freeware with Source Size: 851 Kb
TDLPortIO is a wrapper for the free DriverLINX kernel mode driver (included).
It allows full port IO under Windows 95/98/NT.
Comes with a C++ Builder and Delphi components,
ActiveX control (for Visual BASIC) and DLL version.
Compatible with the shareware package TVicPort.


If you are into making your own electronic devices, you might also be interested in the USB modules from For about $20, you can buy a little unit that plugs into a Win98 or higher machine via USB. On the "outside world" side, it has 8 bidirectional digital input / outputs, and a few handshake lines. The programming isn't trivial, but there is great material about accessing the device. Illustrations in Delphi are provided. You either install a TComPort component (a freeware one, with Delphi source code is available from Dejan Crnila and then access the 8 bits as if (to Win98) they were on a COM port, OR you use a DLL (supplied royalty free from FTDI). It is not exactly a parallel port via USB, but that's roughly the idea.

Apologies to those of you who've read all of this page carefully... you will have seen this item above... but many people just skip web pages, and I want everyone to know I have designed a parallel port protector that may be of interest. (That page opens in a new window, so you won't lose this page... and it gives you access to the circuit diagrams.) It puts opto-isolators on 4 lines, so you can connect (almost) anything as an input, and puts relays on the other 4 parallel port lines, so you can send outputs to control things easily.
For Delphi programmers: Tutorial: A free DLL to access the printer port, and how to use it..

For Delphi 2 (and above) programmers: Tutorial: How To Access A Joystick.

A page with this page's editor's eddress is available if you want to send feedback or ask a question about something here. (You can probably get faster and better answers to "How do I...?" questions via Google.)

Haven't found what you wanted? Click here to go to a further page consisting mainly of links to other resources.

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? At least (please) send an 'I liked the parallel port use page, and I'm from (country / state)' email? (No... I don't do spam) Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Don't forget to check out the programs for writing to or reading from the parallel port at my freeware and shareware site. All of the software is only for Windows, I fear. Most of my software will run on anything from Windows 3.1 to Vista and probably beyond... but the ones that interact with ports tend to be restricted to "before NT (pr XP)" and "after Win98" because of OS issues determined in Redmond.

The editor of the page you are reading also offers you a general 'electronic projects' page.
Why does this page have a script that loads a tiny graphic? I have my web traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try it, check out eXTReMe's site

Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at

- - - - Page Ends - - - -