Slashdot Mirror


Control 8 Electrical Devices With Your Parallel Port

Michael Williamson writes "A PC parallel port can provide 0 or 5v on 8 pins, individually controllable. This can be used to directly drive LED lights, or with the addition of an external power supply, some switching transistors, and some relays, control 8 higher-powered devices. I've written a handful of example programs that drive a homemade 8-LED display in amusing ways."

36 of 48 comments (clear)

  1. I've just built something like this by skinfitz · · Score: 3, Interesting

    I got a relay kit from Carl's Electronics which switches 8 relays and works brilliantly. Great fun!

  2. Nice coding, Tex by ObviousGuy · · Score: 3, Funny

    value = pin[0]*1 + pin[1]*2 + pin[2]*4 + pin[3]*8 + pin[4]*16 + pin[5]*32 + pin[6]*64 + pin[7]*128;

    And they say Perl looks like line noise.

    --
    I have been pwned because my /. password was too easy to guess.
    1. Re:Nice coding, Tex by n1ywb · · Score: 1

      Jesus! Flamebait!? What are you smoking and where can I get some?! Mod parent up.

      --
      -73, de n1ywb
      www.n1ywb.com
  3. 8 Devices? How 'bout 256? by forsetti · · Score: 2, Informative

    With a few extra chips (decoders), it would be awfully easy to control 2^8=256 devices. Note that I said "control", and not "drive". You will definitely need some external power to drive this....

    --
    10b||~10b -- aah, what a question!
  4. Can be done with a serial COM too! by curious.corn · · Score: 2, Informative

    Take a diagram like this and add another line of FF on the outputs to mask the output while shifting... (say, DTR will shut them keep/thru, RTS to strobe... use CTS on a dead FF or buffer to sync for propagation delays) Heh, can you buy FF sticks anymore? it would be fun to play with...

    --
    Mi domando chi à il mandante di tutte le cazzate che faccio - Altan
    1. Re:Can be done with a serial COM too! by baywulf · · Score: 1

      Note that a serial port doesn't use 0V to 5V logic levels. Instead it is 15V to -15V. You would need to use a level shifter such as a MAX3232.

  5. USB parport by n1ywb · · Score: 2, Interesting

    I can't belive people are still using the parallel port. I just finished my first project using USB for my interface, and it was pretty easy overall. I guess not as easy as using the parallel port, but then again I can control 127 USB devices, and each one could be controlling an arbitrary number of other devices. I would like to see some decent USB experimentation products and drivers out there. Maybe I'll hear my own calling.

    --
    -73, de n1ywb
    www.n1ywb.com
  6. Coffee by infernalC · · Score: 2, Informative

    There has been a HOWTO for controlling an automatic drip coffee machine for years using your legacy paraport. See Coffee HOWTO.

  7. Wow, this is so recent by MerlynEmrys67 · · Score: 1
    Hmmmm... lets see my senior project controlled a radio telescope using the parellel port 10 years ago... wasn't even considered new then, there were internet sites telling you exactly how to do it (well I/O through the parellel port, we had to handle the D-A conversion ourself)

    I guess it just suprises people when they use an I/O port to do I/O

    --
    I have mod points and I am not afraid to use them
  8. Also, by Anonymous Coward · · Score: 1, Informative

    There are other neat computer chips out there that will light up LEDs or perform logical functions, or whatever you want. Start here.

  9. Here's a useful one.. by i_am_nitrogen · · Score: 1

    You can control the lights at a party with a setup like this (yes, I've done it with relays) with this cool Open Source XMMS plugin: Palace. I'm working on a circuit that uses a 1-in-16 demux and 16 74ls373's on the 4 control pins to run 128 LED's (though I haven't had much time to spend on it).

    Disclaimer: I wrote Palace. It used to be based on XPLSISNJASP (can't reach its project page anymore), but most or all of that old code has been ripped out and/or rewritten.

  10. Re:USB parport by PD · · Score: 1

    How about some schematics? Or maybe a pointer to a website on how to build some hardware?

  11. Re:8 Devices? How 'bout 256? by Papineau · · Score: 1

    With a few extra chips (decoders), it would be awfully easy to control 2^8=256 devices.

    Wouldn't it be 128? You do need a line to control the chosen device, ie on/off.

  12. Re:USB parport by n1ywb · · Score: 2, Interesting

    I used Microchip's USB PICs. They'll send you free samples, although you'll need to be able to program them somehow. I won't go into the details of getting started in PIC programming, you can google for that and find 1000 pages. They supply USB firmware, which is pretty easy to use. Just define your descriptors (this will require reading parts of the USB spec), and then put copy your data into a buffer and put the number of bytes in W and call their library routine. Data sent.

    If you look at the data sheet for the PIC 16c745 and 16c765, you'll find schematics. It's damn simple, you add a cap and a resistor and a USB connector and the thing powers itself off the bus.

    --
    -73, de n1ywb
    www.n1ywb.com
  13. I would love to be able to lit up any LED but by eggstasy · · Score: 1

    I dont know much about electronics or physics or anything :(
    I once tried wiring a led to an AA battery but it didnt do squat, lol.
    I wouldnt even know where to get electronics material. There is no radio shack in Portugal :(
    If anyone knows of a fool-proof tutorial on led-play for the utterly clueless dummies like me, I would kill to be able to make a battery-powered led constellation to hang on the wall.

    1. Re:I would love to be able to lit up any LED but by QuMa · · Score: 1

      LEDs are diodes, which means they only conduct electricity (and in doing so give of light) in one direction. Usually on LEDs the shorter of the two leads is the cathode, which means the side that's to be connected to the negative side of the battery. The other side (the anode) connects to the positive side of the battery.

  14. Re:8 Devices? How 'bout 256? by lowtekneq · · Score: 1

    You could also boost the amount of devices using only transistors. You have 8 basic imputs, add a few transitors to make AND/OR gates and the rest is common sense from there. The best use of this (other than the want for more devices ofcourse) is so you can use a thinner cable. UTP Cat5 cable is cheap, but it only has 4 pairs, so eight wires, one has to be the ground. So now we have 7 data wires and 1 ground. 1 - 7 1 AND 2 - 1 AND 7 2 AND 2 - 2 AND 7 3 AND 3 - 3 AND 7 4 AND 4 - 4 AND 7 5 AND 5 - 5 AND 7 6 AND 6 - 6 AND 7 7 AND 7 ... same goes for OR, if you really need connections you can go even deeper (2 AND 4) OR (5 OR 6)

    --
    Carpe meam simiam!
  15. Controlling a parallel port with Perl! by Ax0n · · Score: 1

    My dear friend and cousin Jerry wrote a nice little Perl Parallel Programming HOWTO for controlling your parallel port with perl.

    He has used this to write an interface app for a Bar Monkey type program. Pictures here.

    --
    -- Morgan Collins [Ax0n] http://www.morcant.net/
  16. Re:8 Devices? How 'bout 256? by Smidge204 · · Score: 2, Interesting

    How about 13 with no extra hardware at all? Standard parallel port (and by "standard" I mean the all the way down to ye olde 8086 machines) have 8 data, 5 control and 4 status (input) pins.

    The only hitch is that four of the 5 control lines are inverted (output a 1 and it becomes a ground, 0 and it goes +5v high). But god forbid you should do any logic or anything :)

    You really can't do much with +5v anyway... so you're likely to drive a set of power transistors / relays to switch lights or motors anyway... which requires extra power.
    =Smidge=

  17. Re:USB parport by PD · · Score: 1

    Question for you before I go off and start surfing on it: Would you say that is a good way to make a device that I could hook up to Linux?

    For example, a little robot with a USB connection, a PIC processor to load memory and maybe the same processor to run the robot or perhaps a different one. Plug robot into my Linux box with USB cable. (Appropriate software on Linux box and in robot firmware). Download new robot program through USB, flip a switch and let it run.

    Never built any really complicated electronics before, but a little microcontroller robot is on my list of things to do or make before I die.

  18. Re:USB parport by Blaine+Hilton · · Score: 1

    You can, but I don't believe there is much documentation on it. I am a Windows programmer, but am starting to learn Gtk programming now. The article at http://usb.cs.tum.edu/usbdoc/ may be helpful to learn about USB on Linux.

  19. Yet another 'been-done' post by ivan256 · · Score: 1

    Done it. Here's the one I worked on back in the early days of college: The Button It's 8 LEDs and a button connected to a paralel port (The button is attached to the select line... We got 9 uses out ouf ours!). When the button is pressed some scripts are run on the host that update this website, turn on the LEDs and other things. What the LEDs do is controlled by this web form.

    This story is so 1996.

  20. Re:8 Devices? How 'bout 256? by qqtortqq · · Score: 1

    I have tinkered a lot with 555 ic's for a while, and for the life of me, cannot find an understandable way to use transistors to replace the relays I am using with the 555's. Can anyone point me to a decent web page describing how to use transistors in my 555 application or in the paralell port device control project that this article is about?

  21. Re:USB parport by Basje · · Score: 1

    I agree on this. Switching 8 channels isn't hard. We did this on a cbm64. It should also be possible in an usb device.

    Many usb devices are way more powerful than the commodore, so it shouldn't be too hard at all to make something like it

    Maybe there are DIY packages for it already.

    It would be nice if I could use all of the expansion port devices I made for the 64 with a modern PC :)

    --
    the pun is mightier than the sword
  22. Dupe by Ratbert42 · · Score: 1

    This is so 1987.

    1. Re:Dupe by Joseph+Vigneau · · Score: 1

      Damn. That's got me beat by a few years...

  23. Re:8 Devices? How 'bout 256? by forsetti · · Score: 1

    mmmm.....well, I would use the standard 8 data pins to select the device, then the 5 control pins to send actions to the selected device.

    Although, it may make more sense to use the 5 control lines as select (limiting you to 32 devices), the 4 low data lines for "instructions", the 4 high data lines for output data, and the 4 input lines for input data.

    Of course, then again, I am definitely spending way to many brain cycles on this.......

    --
    10b||~10b -- aah, what a question!
  24. Do it from Python by L3WKW4RM · · Score: 1

    I recently wrote a Python C extension for doing just this. It's nice to be able to twiddle bits back and forth realtime from inside the Python interpreter when you're debugging hardware.

    Download it here: PyPortIO

    Use it like this:

    import portio

    lp0 = portio.Port(0x378)
    lp0.outb(0xFF)

    There's also a good list of links for reading up on more projects there.

  25. How about input? by phorm · · Score: 1

    As per the recent survey on fun ways to reboot one's PC, and the mention of reading "sleep" buttons on 'nix...

    How about some more basic instructions on how to configure 'input' devices on the parallel port, and then maybe some programming tips (windows and 'nix both) on how to work with them.

    Personally, I've been wondering if I could make my own input-device. Maybe a DDR floor panel or something? Or just I/O, with panels that light up as well as sending back info. How about it?

  26. Re:USB parport by ivan256 · · Score: 1

    Would you say that is a good way to make a device that I could hook up to Linux?

    It certainly is. If you use the USB scanner driver (which actualy isn't necissarily just for scanners at all) you can write all your control software without having to change kernel code. Your favorite distro almost certainly has the scanner module built already. Personally I find writing a kernel based driver easier (probably because it's what I do for a living and I'm used to it), and you can do that too.

    If you want to access your device from the kernel, the Programming Guide for Linux USB Device Drivers is where you should start. If you don't want to mess with the kernel, read the scanner.txt file that comes with the kernel documentation. There's an example program at the bottom that uses the scanner driver to talk to an HP scanner, but the device at the other end of the cable can be any non-scanner device too.

  27. Re:Is this a slashdot story? by Mr.+Slippery · · Score: 3, Interesting

    Yes, it is a good /. story.

    Believe it or not, there are geeks who've lived only in the software world, and never even picked up a soldering iron (sad but true), but would like to learn a little. A simple electronics project that gives them a taste of the hardware world is just perfect for them.

    --
    Tom Swiss | the infamous tms | my blog
    You cannot wash away blood with blood
  28. Reminds me of the time... by character+sequence · · Score: 1

    back in '88 or so, I built a parallel-port D/A converter and wrote some DOS drivers for it (in *assembler*, baby). It produced pretty good sound quality, after downloading some 12-bit samples from a borrowed MIDI sampler - beat the hell out of trying to modulate the PC speaker by switching it on or off at about 100kHz.

    --
    Karma: Nonnegative
  29. Old news but still good value by Ashtead · · Score: 1
    The joy of making things work, even if it seems trivial to some seasoned expert, is not to be undervalued! Controlling things through the parallel port may not be novel, but learning how to use it to turn on and off LEDs and relays is still worthwhile.

    There is this wonderful connection between the 1's and 0's of software actually appearing as electrical signals with one or the other voltage on them.

    I have preferred connecting something to the serial port myself, since that was easier to get working under the Windows NT family of operating systems. However, with Linux, the parallel port is just as straightforward as the serial port, and offers a lot more signals.

    --
    SIGBUS @ NO-07.308
  30. DDR pads are even simpler by stile · · Score: 1

    If you're playing DDR on a playstation, you just grab a $5 knockoff playstation controller and wire to the button connectors on the circuit board. I did this, using heavy modifications on the design found here. If you're playing on the PC, I think you can then just get an adapter to convert the playstation controller to USB.

  31. Just finished doing this on a microcontroller by xtal · · Score: 1

    This is really easy, and cheap to do. LEDs shouldn't need any extra components - most bright ones you should be able to drive directly without causing any problems.

    For control, you need a few extra components, but not many. A TIP122 or similar power switching resistor (a cheaper 2N2222 might work, dunno) and a 12V power supply can be used to control dirt-cheap automotive relays. The only (minor) gotcha is you need to hook up a diode in reverse across the coil to stop the back EMF. A 1N4002 connected with the negative cathode (the pin with the line on it) to the port on the solenoid you connected to +12 is it. The coffee FAQ has a good starting schematic. Once you can control a relay, you can control the world!

    All you need to connect this up is a small value resistor from the parallel port to the base pin of the transistor, connect the relay solenoid between +12 and the collector pin, then tie the emitter to ground. Done!

    Another neat trick is using that TIP122 to control the extra fans on your PC. You should wire up a reverse diode across the base and collector of the transistor to protect it from the fan as a safety measure, though.

    If anyone is interested in this, though, I highly recommend you look at AVR microcontroller programming. You can use GCC, there's free linux and windows development tools, in C, and more examples than you can shake a stick at. The ability to communicate over serial lets you do all sorts of tricks with your PC.

    --
    ..don't panic
  32. controlling fans by asquared256 · · Score: 1

    On my computer, the fans are controlled by something like this. I just used 4 2n2222's and used two parallel port lines, one with a 10k and the other with a 5k resistor, on each so the speed was variable. I'm thinking of adding some 74HC595 shift registers to get more outputs - these can be chained to get virtually as many outputs as you want. I also added some buttons to override the computer control, if necessary. The hardware's a mess but it works well with the software I wrote (the fan speed increases when the case temp rises or cpu usage increases.)