Hooking Up a 7 Segment LED to a Parallel Port




Introduction: Hooking Up a 7 Segment LED to a Parallel Port

About: Writer, engineer, techie. I've been using computers since the original Apple II in 1978 and have always been interested in technical topics. Check out my articles on neatinformation.com. They include how-to...

This instructable can be accessed at the author's website - http://www.neatinformation.com/
If you link to this instructable from another website, please include a link to the Neat Information website.

The project described in this article requires basic electronics skills and is provided for information purposes. Do not attempt to replicate it or use it for any purpose unless you've got the proper knowledge and skills.

It’s incredibly easy to hook up a 7 segment LED display to a computer’s parallel port. I first did it 30 years ago with my original Apple II and the first accessory I got for my Apple, a parallel printer card. The primary purpose for the card was naturally to hook the Apple to a printer, but the manual mentioned that it could also be used as a “general purpose, 8-bit parallel output port.”

Many new PCs, especially notebooks, don’t have parallel ports anymore. They’re easy to add to desktops though, you can get a PCI parallel port card for under $10. Even if your computer has a built-in parallel port it’s still desirable to use a PCI parallel port. That way if you make a mistake and end up damaging the port you’ve only damaged an inexpensive card instead of potentially damaging your entire motherboard.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Intro

The circuit is incredibly simple. There’s just 10 parts - one 7 segment common cathode LED display, 7 resistors, one piece of hook-up wire, and a DB-25 male connector. It shouldn’t cost more than $5 for the parts and you may already have them in your junk box. The resistor limits the amount of current that goes through the LED. The optimal value depends on LED’s voltage and current, in my case 150 ohms.

I used a small solderless breadboard to assemble the circuit; in fact the same one which I used to build the same circuit for my Apple II experiments three decades earlier! (The resistors and 7 segment LED are new, I tossed away the old components many years ago).

Circuits like this have been used for practical applications – a counter to indicate the progress as a computer boots up, an indicator of the computer’s performance level, etc.. I originally made this project primarily to learn a little bit more about electronics and my Apple II, but also because it’s fun. I decided to rebuild the project for a current PC parallel port for nostalgia and also to show some of the principles used with early microcomputers.

In the early days of microcomputers we didn’t have gigabytes of memory or terabyte hard drives. Every line of code was precious so programmers learned from the start to write efficiently. (My Apple II came with just 16K of RAM - less memory than a current high end calculator.) The efficiency even extended to hardware designs. Steve Wozniak came up with the revolutionary idea of using a single timing crystal. It generated signals both for the microprocessor and the color burst signal necessary for color video output. The memory was refreshed by the same circuit which controlled the video. Woz recognized that if he could do something in software rather than hardware it would save money in the long run. Once software is paid for it can be reproduced very inexpensively, in contrast hardware has to be purchased for each unit made.

I’ve seen a circuit for connecting a 7 segment display to a printer port that uses a chip specifically designed to convert incoming data into the correct signals for a 7 segment LED. All you have to do is send your data to the printer port. I’d rather save a chip and do the conversion through software.

Step 2: The Circuit

You will need a common cathode 7 segment LED. Common cathode means all of the LEDs's cathodes are connected. Every 7 segment LED I’ve seen uses the same designations for each of its LEDs – alphabetical from A to G with A at the top, and then proceeding clockwise with G the middle segment. If there’s a decimal point it’s designated DP and is an eighth LED. Which pins on the 7 segment LED module are connected to which segment does vary. You’ll have to use a manufacturer’s spec sheet or experiment with a voltmeter to determine the correct pins for each segment.

The circuit is incredibly simple, connect the seven resistors to the parallel port output’s D0 through D6 pins. Wire the resistors from outputs D0 through D6 to segments A through G in order, or the incorrect segments will light up. Finally, connect a wire from the 7 segment LED’s cathode to the ground pin on the printer port. If you want to connect the decimal point connect it to pin D7 through its own resistor.

Since this is just a prototype I didn’t bother to insulate the exposed wires on the resistors. You should take care to ensure that the wires aren’t shorting each other. (Nothing bad should happen if any of the resistors are shorted but the wrong LEDs will light up. I take no liabilities if something unexpected does happen or damage occurs for whatever reason.) The ground wire is insulated because it most certainly will cause problems if it’s shorted to one of the data lines.

I use a Male to Female DB-25 extension cable so the solderless breadboard can be placed on my desk instead of on the back of the computer where the parallel port is located, but there’s no reason it can’t be attached directly to the printer port.

Step 3: The Software

I created a lookup table which determines which LED segments will light up for each number. For example, the number 4 is generated by lighting segments B, C, F, and G. There are a couple of arbitrary choices though, in particular whether or not you want to include the top horizontal LED (A) in the number 6 or bottom LED (D) when displaying 9.

This table shows which LEDs will light for each number –

0 A, B, C, D, E, F
1 B, C
2 A, B, D, E, G
3 A, B, C, D, G
4 B, C, F, G
5 A, C, D, F, G
6 C, D, E, F, G
7 A, B, C
8 A, B, C, D, E, F, G
9 A, B, C, D, F, G

If you’ve wired outputs D0 through D6 to LED segments A through G in order, then each letter will correspond to simple binary math. A is 1, B is 2, C is 4, D is 8, E is 16, F is 32, and G is 64. Just add up the corresponding numbers to each letter and you’ll come up with this chart –

0 63
1 6
2 107
3 79
4 102
5 109
6 125
7 7
8 127
9 103

These ten values are the numbers we have to send to the printer port to display each number. One advantage to the software approach is flexibility. Since you can program any combination of the seven segments you can create various symbols and letters. About two thirds of the English alphabet can be generated with 7 segment displays (if you accept a lopsided “Y” and use lower case for d, n, and r). It was popular to come up with numbers which would generate short phrases on your calculator; although for some of them to be viewable you’d have to turn the calculator upside down. Coming up with the correct lookup table for “ShEll Oil” or “boobiES” is left as an exercise for the reader.

I decided to write the program in BASIC, as I originally wrote it. Unfortunately Woz’s Integer BASIC will not run on current computers (other than Apple II emulators) so I selected FreeBASIC.

FreeBASIC is an excellent open source BASIC compiler which builds on QuickBASIC. Most important for this project is built-in support to address ports directly (the equivalent of the POKE command in Integer BASIC). That’s right – we’re going to bypass APIs and other modern programming techniques and send data directly to the hardware port. This means this program will not work with USB to parallel converters who do not emulate the printer port perfectly.

&H378 is the default printer port address. It’s set in your computer’s BIOS and you can change the value in this program to whatever port you want to use if for some reason you’re using an alternate address. If you aren’t using a PC with a standard printer port you will have to adapt the output routines in my program.

Step 4: The Program

The program’s extremely straightforward and should be easy to follow or translate into another flavor of BASIC or any other programming language.

' LPT port 7 segment LED display

' Set 640x480 mode, 256 colors
Screen 18

Dim As Integer x
Dim As Integer y(10)

' read data
For x = 0 To 9
Read y(x)
Next x

' countdown loop
For x = 9 To 0 Step -1
Out &H378, y(x)
Print x
Sleep 500
Next x

' clear printer port
OUT &H378, 0


Data 63, 6, 107, 79, 102, 109, 125, 7, 127, 103

It was a lot of fun redoing a project which I had first made so many years ago. While this is a simple project I hope it's a good tutorial for somebody starting in electronics or interfacing simple devices to your computer.

Be the First to Share


    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Arduino Contest 2020

      Arduino Contest 2020

    5 Discussions


    8 years ago on Introduction

    Very interesting, Philip.

    I suppose that doing this for two or more digits would be a bit more difficult, is it so?


    Reply 8 years ago on Introduction

    I can't even fit a second digit on to the little breadboard I have! But seriously - this is just a learning exercise, not a design which is intended to be expanded.

    To add a full second digit, or the more general solution of N-digits you'd need to do some multiplexing and persistence of vision which is simple enough to do with additional chips.

    There may even be a specialized chip which converts 8-bit binary outputs into the 7 segment displays and will display any number from 0 to 255. If not it could certainly be done with discrete components. The alternative would be to use a simple microcontroller.


    8 years ago on Introduction

    Hey do me a favor and measure the current you are pulling out of your port doing this. I'm taking a poll.