4

Hila Research Centre

Computer Engineering Program

Parallel Port

The parallel port (where you connect your printer) can be used to send electrical signals out of your computer. These signals can be used to switch lights off and on, control robots or launch a model rocket.

Caution! It is possible to damage your computer doing this type of experimenting. Proceed only if you have some knowledge of electronics and an inexpensive computer - a 286 is an excellent computer for doing this type of electronic interfacing.

The parallel port has 25 pins or connection points. Each of these pins is numbered as shown. If you look closely at the port on your computer the pin numbers may be visible.

Pins number 2 to number 9 can be switched on (+ 5V) using Qbasic. These pins represent an 8 bit binary number. The value of each pin is as follows:

• Pin #     Value
• 2             1
• 3              2
• 4              4
• 5              8
• 6              16
• 7              32
• 8              64
• 9              128

To turn any of these pins on, use this Qbasic command:

OUT (888), n  (n = binary value of the pin(s) to be turned on)

The current available at the parallel port is very small (2 to 10 mA). For this reason you must use devices that don't require large current. Low current LED's with a 1 K resistor work OK. The circuit shown below turns on an LED connected to pin 5, pin 25 is a ground pin (minus). Pins number 18 to 25 are all ground pins. The metal casing is also ground.

To turn on more than one pin, use binary combinations of numbers. As an example, if you wish to turn on pins # 3, 5 and 8, look at the chart and add up the binary value (2 + 8 + 64 = 74). The Qbasic command to turn these three pins on is: OUT (888), 74

Here is a short program that will switch the LED connected to pin 5, off and on in 1 second intervals.

• CLS
• DO
•       OUT (888), 8
•       SLEEP 1
•       OUT (888), 0
•       SLEEP 1
• LOOP WHILE INKEY\$ = ""