Interfacing LEDs using the Parallel Port

If you haven't read my previous article "Basics of Parallel Port" then I would suggest you to read it first.



Introduction

In this article I will first tell you about how to build the LED interface circuit for the Parallel Port and then how to control the circuit using software. With this very basic prototype you will be able to learn a lot how the parallel port works. So, I'll start with the circuit first.

Circuit Diagram

Interfacing LED using Parallel Port
Circuit Description


Components Used:-
  1. Eight RED colored LEDs
  2. DB-25 Male Connector
  3. Zero PCB
  4. Ribbon Wire
All you need to do is to connect each data pin from the parallel port (pins 2 to 9) to positive terminal of a LED and one ground pin (any one from 18 to 25) to the negative terminal of all the LEDs.
Since LEDs have polarity, you should pay attention to correctly locate its positive and negative terminals. If you pay close attention, you will see that LEDs are not completely rounded, the cathode side is a little bit flat. Also the longer leg of LED is anode or positive terminal and the shorter leg is cathode or negative terminal.

LED Pinout
How the circuit works?


Working of this circuit is pretty simple. When data at any pin 2 - 9 is '1' , that particular LED will glow, else if data is '0', the LED will stop glowing.

When data at any pin from 2 - 9 is '1',then it means that 5 volts is coming out of that pin and is going towards +ve terminal of LED. Circuit gets completed through ground pin (any from 18 to 25) and the LED glows until data at that particular pin is not '0'.

This data flow is controlled using software discussed below.

Software

To control any port we need a kernel mode driver software. Softwares generally run in USER mode. But to control the Parallel Port we need a software running in kernel mode. I have used C#.Net for developing this software.
  1. Download and install Microsoft .NET Framework Version 2.0.

  2. Now download and install My Parallel Port Control Setup.

  3. Download the source code in C#.Net.
For more info on software click here.

In The End

This article was just an building block to the parallel port interfacing.

Now you are ready to make your second parallel port controlled device. Read my next article on Interfacing RELAYs using the Parallel Port.


40 comments:

mark said...

hi there can u give some program in C or VB,regarding how to control a LED connecting in a parallel port,and a Circuit,i have to control a 30 pcs of LED...Thanks,,,,can u email it to me at mark_pineda82@yahoo.com

Anonymous said...

Hi
this is really interesting, keep on posting more of this kind please,
BTW, if you have the codes in VC++, please upload them as well

thanks
Hojjat

vijumohan said...

Hi..
can you plse help me regarding parallel port program in C.....i want to test output of 7 meters at a time using c program ...i want to get the output pulse in a graph...so that we can see which pulse is showing error...now am taking each 7 outputs to each each d0 to d7 of parallel port....and from that am taking pulse and showing in graph......in this stage i got stuck...if u have any idea how to do this plse help...as i dont have much knowledge in c language i dont how to show this 7 pulse in a graph at a time....if you have any sample code plse help....its urgent...ASAP...

vijumohan said...

id is vijunambiar@gmail.com

Jaspreet Singh said...

Hi vijuana...
we cannot connect the outputs directly to the data pins of the parallel port....
for this we need an interface in between....
use IC 74HC245 for this purpose...

for more info visit this page:-

http://www.xs4all.nl/~jwasys/old/diy2.html

and one thing more...
C program for parallel port will not work on 2000, XP etc.

u need DOS or windows 98 to run C program for parallel port...

PEOPLE FOR ANIMALS said...

hi..
nice to see these types of posts..
referring to the previous comment abt C program not being run on xp/nt/200 etc.

you can run the program on these os's but you have to copy a dll file named as inpout32.dll to the windows system folder. then the functions like outportb() etc would work easily

Anonymous said...

hi!! could you send me the code of that program in vb? please!! tooperfects@yahoo.com. thanks

Anonymous said...

sir, how will control 40-50 leds in one parallel port?

Anonymous said...

sir
how will i control 40-50 LED's in one parallel ports...I need it in our project....thanks in advanced..

send any suggestion or link that would help me on this email add auslogic214@yahoo.com

Jaspreet Singh said...

To expand the parallel port output we can use 74HC374 IC (D Flip Flop IC).

Output of the parallel data port is connected to the input of a 74374 IC and one control pin is is connected as clock of the 74374 IC.

Similarly, we can connect 3 more 74374 ICs with each having a different control pin as clock.

But this arrangement will give only 24 outputs pins.

To get more outputs we need more ICs or rather more clock signals.
For more clock signals we can use 3x8 decoder IC - 74138.
Apply 3 control pins as input to 74138 IC and get 8 signals at its output that can be used as clock signals for eight 74374 ICs. Thus, using 74138 decoder we can have 7x8 os 56 output pins from 8 pins of the parallel port.

Unknown said...

sir software shows that no parallel port detected on this computer.
please help me

Unknown said...

sir,
I have installed a new pci to parallel card.it is working fine.i am able to print using the port but the when i open your application it says that no parallel port detected on this computer
please help me sir i am very much interested

Unknown said...

sir,
my email id lifeonmoon2010@gmail.com

Jaspreet Singh said...

@Simhadri
Software works with on board parallel port only. It doesn't works with PCI to parallel card.

Unknown said...

sir,
i dont have an onboard parallel port
i brought the pci to parallel card for this purpose.do i have any option please help me sir
i want to do it.i will get any other accessory for it.

Jaspreet Singh said...

@Simhadri

View this page :-

http://logix4u.net/Inpout32.dll_Discussion/PCI/Parallel_Port_Card_Troubles.html

Unknown said...

thanks a lot sir,i think this would help me out.i will write to you again.

Simplifier said...

IS it necessary to use status and controls pins all the time, i m using ULN2803 with 8 LEDs and i want LEDs to glow one by one through an array.

Jaspreet Singh said...

@Simplifier
For 8 LEDs we can always use the 8 DATA pins. No need of any control or status pins.

Simplifier said...

It looks simple but i can't get output on the data lines, my OS is WINXP so i copied Inpout32.dll in the system and system32 folder plus i m using outprotb(0x378,0xff) to make all eight pins high but still not a single LED is on. plz help

Jaspreet Singh said...

@Simplifier
Which programing language are you using?
I have tested it in C# and VB and it works fine on XP.
But with "C" language it doesn't works on XP.

Unknown said...

it will be better sir if u explain your source code in any language c# or vB because we some people know how to code bt didnt know how to code to control a hardware through source code so we are waiting for that :)

Ahmar said...

HEY Jaspeet, i want to control 10 Leds through parallel port using 138 or 139 demux, please email me the C program for that and also the IC Connections ASAP.
Thanks.
my email is krulex@Live.com

satya reddy said...

hi this satya
can u please send me the source code of your parallel port control software..........
my mail id is
satya.anugu@gmail.com

Faizan Rauf said...

i have m68m-s2 gigabyte board and on-board parallel port but program is saying no parallel port detected on this computer
ab kia karun

Jaspreet Singh said...

@Faizan Rauf

Check the BIOS settings. The Parallel port might have been disabled from the bios.

jeremie said...

gud day sir,

i just want to have a copy of of the source code of the "parallel port"...it is because i want to know the functions used and I prefer language in C if there's any..thank you sir and God bless.

Jaspreet Singh said...

@jeremie

Source code is available in C#.Net only and the download link is given at the end of the POST above.

Anonymous said...

Thanks

himanshu said...

their is no parallel port in my laptop.Can i use "usb to parallel port converter"?


it work properly or not?

Jaspreet Singh said...

@himanshu
Software works with on board parallel port only. It doesn't works with usb to parallel port converter.

Anonymous said...

how im make this by usb it's possible?

Jaspreet Singh said...

It is possible with USB but more complex hardware is required including controllers like PIC.

Aryan Singh said...

Hey Jaspreet !
I connected a 6V bulb, which works perfectly when connected to 4.5V or 6V power supply, to the parallel cable. I used your program, but the bulb dint light.
I am now using WIN XP 32 bit.
I used bulbs cz i cannot find resistors here..
Thanls :)

Jaspreet Singh said...

@Aryan Singh said...

Parallel port can't provide enough power to drive a 6V bulb. Use LEDs instead.

Bhagzi said...

I have written a program to detect faces (using OpenCV) in C++.

I also tried out the relay interfacing and ran your setup and with the application I was able to turn ON and OFF the lights.
Thanks a lot for that.

But the problem is I have to integrate these two:

I actually want to automate the process. So whenever the face is detected a signal is sent through the parallel port to the relay.

That is why I want to know if its possible in C++ (parallel port programming)?

I am using XP 32-bit.

If that's not possible, any other solution will also be appreciated.

Like is there a way of calling the C# method from the C++.

As a matter of face there is a way for that but I don't know which method to call.

Thanks a lot in advance and for such good articles.

Bhagzi said...

Please reply as soon as possible. Thanks :-)

Anonymous said...

sir software shows that no parallel port detected on this computer.
I have on board parallel port.I have connected a led bulb to port and is continue glowing. USING O/S WINDOWS 7.

Anonymous said...

Please reply i am very excited.

Unknown said...

hi there.

i have here a usb to db25 male cable(because i dont have parallel port in my Motherboard), and it connected to my db25 female connector to 9 pins so that i can try to testing it by using leds. but unfortunately ur program cannot detect my usb to db25 male connector. how can i fix that?