Reading/writing to parallel ports.

PsychoPy doesn't (yet) have any built-in parallel port handling. If you want to communicate with these ports from a windows box you will need winioport.

Download winioport and install as instructed.

You can then control your parallel port with commands such as:

import winioport
LPT1 = 0x378 #on most PCs this is the address of the parallel (printer) port
winioport.out(LPT1,0xFF) #set all pins on LPT1 to high
winioport.out(LPT1,0x00) #set all pins on LPT1 to low
winioport.pportD0(1)      #set pin 2 to high (which is data bit 0)
winioport.pportD1(0)      #set pin 3 to high (which is data bit 1)

Often people use hexadecimal codes to control the bits (eg. 0xFF) but you might find it more intuitive to use an integer conversion of a binary string like this:

winioport.out(LPT1,int('00000010', 2))# turns pin 3 to high and all others to low
winioport.out(LPT1,int('11111110', 2))# turns all except pin 2 to high
Valid XHTML 1.0! Valid CSS!