Vous êtes sur la page 1sur 3

Connecting LEDs to the Parallel Port

It looks fancy but it doesn't do much except that it is a good way to test your parallel port and above all clear your concept clear as to how the Parallel port works. In order to accomplish this task you will need the following: No. Name 1 LED (Light emitting Diodes) Any color 2 Resistor 470K Ohms or so Old discarded PC to Printer Cable (if 3 possible) Quantity 8 8 1

The last item can be expensive to buy, so try to use an old discarded printer cable, or at least a cable whose one end is a female Connector which connects to PC and the other end is bare wires coming out. Also make sure that you if you buy this cable, purchase one whose connectors can be opened. Not the one which are completely molded plastic. The resistors is needed to limit the current taken from parallel port to a value which light up acceptably normal LEDs and is still safe value. In practical case the output current will be few milli amperes for the LED, which will cause a typical LED to light up. Now the next step is to attach LEDs to the printer cable. If you are using a printer cable, you will need to open up the centrionics connector (the end which connects to the printer) and cut the wires from the metallic connector. If however it is a completely plastic molded you will have to cut the centrionics connecter away . Next open the RS32 Female connector i.e. the end which connects to the PC. Observe the wire colors which are connected to the Data pins and Ground Pins of the port. To remind you the Data pins are Pins 2 through 9 and the Ground 18 through 25.The connector face usually has pin numbers inscribed on it so you can see it quite easily. Note down the color of the data pins and the ground pins. The Ground pins are usually all connected to one wire. They are all common ground. Connect the LEDs according to Fig 1 shown below. Connect the circuit to the parallel port so that one end of the circuit goes to one data pin (that one you with to use for controlling that LED) and another one goes to any of the ground pins on the other end of the cable. Be sure to fit the circuit so that the LED positive lead (the longer one) goes to the data pin. If you put the led in the wrong way, it will not light in any condition. You can connect one circuit to each of the parallel port data pins.

Fig 1: LEDs connected to Parallel Port [Enlarged View] That's it now you are done. Recheck the connections and make sure they are according to the Diagram, tightly connected and observe all precautions, because a little neglect can blow up you PC, as you have read at the start of this section (Read them if you haven't). You can fit your LEDs in the centrionics connector case a I have. See the photo below.

Photo 1: LEDs connected to the Parallel Port [Enlarged view]

Controlling the LEDs connected to the Port


Before continuing Read about Parallel port Now to control the LEDs connected to the Parallel port through software you will need to know any programming language, like Assembly, C, C++ etc. It is quite easy as we will see. You can also download my program which I have written in VB. It

allows you to turn LEDs on/off connected to the 8-Data pins of parallel port, Click on the link to your right to download it now.

Assembly Language
Here we will proceed with assembly. Now as you know to turn any one of the LEDs I'll just pass a value to the port like this: ORG MOV MOV OUT 100h DX,03BcH AL,255 DX,AL ;Port Address ;Data: All LEDs on

To write to the eight data registers we can pass a value of 0 - 255 at the parallel port address. In Binary every bit of that number controls one or more output bit. Table below illustrates them. DB25-Pin Data Pin Value 2 0 1 3 1 2 4 2 4 5 3 8 6 4 16 7 5 32 8 6 64 9 7 128

For example to turn on LEDs 2 and 3 to logic 1 then output value would be: 1+2=3. Similarly to set on pins 3, 5 and 6 then output value would be: 2+8+16=26. In this way value for any bit combination can be calculated. Also it should be noted that: Value 0 255 Description All LEDs OFF All LEDs ON

Vous aimerez peut-être aussi