HOW TO PROGRAM THE PARALLEL PORT ON A COMPUTER USING C/C++

New versions of windows operating system does not support direct access to I/O ports.
In order to communicate with the parallel port of your computer in windows operating system you will need a driver called inpout32.dll which you can dowload from here http://logix4u.net/parallel-port/inpout32_source_and_bins.zip

Extract the zip file , open the binaries directory , copy the inpout32.dll and add it to you projects directory.
you can also save it at "%systemroot%\system32\drivers"


The address of the parallel data port is 
0x378-0x37F for LPT1
0X278-0X27F for LPT2
Parallel port has 8 data input

fig.1

DATA PORT PIN NO.
SIGNAL NAME
BYTE TO ACTIVATE PIN
2
D0
0x01
3
D1
0x02
4
D2
0x04
5
D3
0x08
6
D4
0x10
7
D5
0x20
8
D6
0x40
9
D7
0x80
18-25
Ground(GND)

All the data port are latching which means it keeps it state once it is activated.
To send one byte to the parallel port  
 send 0xFF to 0x378
1 bit will be on each data port which means all the data port will have 5V across them
To send 1 bit to Data port 
If you send 0x01 to data port 0x378 will send binary 00000001(5V) to pin 1
and so on as shown on the table.

Now to start create a new cpp file  and note the inpout32.dll should be in the same folder or you can place in this directory %systemroot%\system32\drivers.

This is how your code should start


To send 1 bit to data port pin 1( D0 ) out(0x378, 0x01) and the rest can be found on the table 

Here is a simple example to demonstrate how to switch the data port of the paraport on and off .
setup a circuit as shown below
fig.2



And the source code is here:

Output display below
fig. 3


With this you can control many appliance and device with the help of a relay.
 The next blog is about How to use the Parallel Port to control a 240 V light bulb

HOW TO PROGRAM THE PARALLEL PORT ON A COMPUTER USING C/C++ HOW TO PROGRAM THE PARALLEL PORT ON A COMPUTER USING C/C++ Reviewed by Zakaria Mohammed on July 29, 2015 Rating: 5

1 comment :

Powered by Blogger.