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."

48 comments

  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!

    1. Re:I've just built something like this by Anonymous Coward · · Score: 0
      This program displays the time in binary on the LED board. It displays the hours (in 24 hr time) for 5 seconds, then the minutes for 5 seconds, goes blank for 5 seconds, then repeats. This is my favorite program. To read the clock, the top light is the 1's, the second is the 2's, the 3rd is the 4's, the 4th is the 8's, etc. Multiply by their place, then add. The time displayed here is 15:09. With a little practice, you can read these at a glance.
      And to think I've been getting by with a digital watch all these years!
    2. Re:I've just built something like this by Anonymous Coward · · Score: 0

      But dude, this is so much more geeky. It's guaranteed to get you some of that fine piece of sexy geek goddess...

  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. Why? by slacy · · Score: 0, Informative

    This is the kind of electronics project I was doing when I was about 12 years old. Why is this worthy of Slashdot? Pretty soon I'm just gonna stop reading this drek.

  6. 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
  7. 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.

    1. Re:Coffee by Anonymous Coward · · Score: 0

      I'm allergic to coffee, you insensitive clod!.

  8. 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
  9. 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.

  10. 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.

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

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

  12. 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.

  13. 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
  14. 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.

    2. Re:I would love to be able to lit up any LED but by Anonymous Coward · · Score: 0

      There is now a circuit diagram on the site linked under the picture of the breadboard.

      Michael

    3. Re:I would love to be able to lit up any LED but by Anonymous Coward · · Score: 0

      You need to put something called a resistor in series with the LED when you hook it up to the AA battery. By "in series" I mean that you should connect one end of the resistor to one end of the battery and connect the other end of the resistor to one of the ends on your LED. Then, connect the other end of the LED to the other battery terminal. Pick between a 300 and 500 ohm resistor and it should light up if you have the LED in the correct orientation. If it doesn't light up, just flip its terminals.

  15. 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!
  16. 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/
  17. 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=

  18. 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.

  19. 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.

  20. 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.

  21. 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?

  22. hello? by Anonymous Coward · · Score: 0

    Welcome to 1990? Seriously I was doing this shit in high school and before that. I even wrote a program and uploaded it to a frickin' BBS! With a frickin' MODEM!

    Let's hear about what people have done with, say, streaming video and firewire... that's a little more interesting.

  23. 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
  24. Re:8 Devices? How 'bout 256? by Anonymous Coward · · Score: 0
    ....+ 5
    .....^
    .....r
    .....|----o
    ...|/
    .i-|
    ...|\
    .....r
    .....|
    ....---
    .....-
    Ignore the periods in the above diagram.

    Where i is your input line and o is your output line. The input line is sort of like a ``flow control'' for the power that goes from +5 to o. If you use resistors above and below the transistor, you can fix it so that when i is 0V, o will be 0V and when i is 5V o is 5V, but the current is coming from the +5 instead of i. You have electrically isolated your expensive computer from whatever it is you're trying to power. This is a MOSFET. BJTs are different, but similar. Using the resistors (the rs) to adjust the transistor levels is called ``biasing.'' The transistor isn't a linear animal. You should really find a book on this, but essentially, the transistor operates linearly when the voltages are in a certain range. You want the transistor to always be in that linear range. Hope this helps.
  25. 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...

  26. Is this a slashdot story? by mnmn · · Score: 0


    Long time ago, when I was little, I hooked some 5.25" drive stepper motors through a multiplexer to the parallel port and controlled it through a program in slackware. But this was a long time ago.

    Now I wonder whats with this news over here? Next week: guess what! A serial port can be connected to another to transfer data!!!

    Please keep my slashdot interesting.

    --
    "Give orange me give eat orange me eat orange give me eat orange give me you." -Nim Chimpsky
    1. 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
  27. 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!
  28. Re:8 Devices? How 'bout 256? by Anonymous Coward · · Score: 0

    Yep, but you will need latches for each otherwise you'll be limited to one-at-a-time control of each of 256 devices.

  29. 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.

  30. 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?

  31. 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.

  32. 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
  33. Yippie skippie by MushMouth · · Score: 0

    I just have one word

    Yawn.

  34. 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
  35. 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.

  36. 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
  37. 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.)