Saturday, March 2, 2013

Using the Data Pins on your parallel port



Controlling the data pins on your parallel port (aka: printer port, LPT1) is fairly straight forward.

There are 8 data pins as shown below:




This is what I did in Linux:

- Install the python parallel port library
  sudo apt-get install python-parallel

- Add your user name to the lp group (that's an 'L', not a '1' or an 'i')
  sudo adduser <username> lp

- Unload the lp modules from the kernel
  sudo rmmod lp

- Load the ppdev (Python Parallel Device) modules into the kernel
  sudo modprobe ppdev

- Then write a little Python script that turns each data pin on sequentially:

    import parallel
    import time

    parPort = parallel.Parallel()

    parPort.setData(0x01);
    time.sleep(1)
    parPort.setData(0x02);
    time.sleep(1)
    parPort.setData(0x04);
    time.sleep(1)
    parPort.setData(0x08);
    time.sleep(1)
    parPort.setData(0x10);
    time.sleep(1)
    parPort.setData(0x20);
    time.sleep(1)
    parPort.setData(0x40);
    time.sleep(1)
    parPort.setData(0x80);

Or course you'll need to wire up appropriate hardware if you want to drive anything with these pins, but that's another project


Check out my YouTube channel:  www.youtube.com/KedarWarriner

No comments:

Post a Comment