Imagine a tri-colour LED. It has 3 pins: two anodes and a common cathode. Now lets say we wanted to control this with a PIC chip, and we only need two colours. Easy, we just tie the cathode to ground and then take two pins from the PIC chip, putting one pin to each LED anode. When we want both LED's off, we just put both pins low. When we want it green, we put Pin 1 high and Pin 2 low. When we want it red, we put Pin 1 low and Pin 2 high. OK, easy stuff. What I'm trying to do though is use one sole PIC pin to achieve this. The PIC pin's three states would correspond to: Pin High = Green Pin Low = Red Pin as Input = Neither Now I've been trying to conceive a transistor arrangement that would make this work. Here's the most promising idea so far: * Get a PMOS and an NMOS * Connect their gates together * Connect the gates to the one sole PIC pin * On the NMOS, connect the source to 5 V, and connect the drain to an LED anode. * On the PMOS, connect the drain to 5 V, and connect the source to an LED anode. (Admittedly I might have mixed up "drain" and "source" here) Now this will work perfectly when the pin is either high or low: * When the pin is high, the NMOS will turn on and light the green LED. * When the pin is low, the PMOS will turn on and light the red LED. Now the problem is what happens when the PIC pin is set as input / high impedence? Is the PIC pin's resistance high enough to ensure that too little current flows to turn on either transistor? Where would I get his information? I'd need to look for something like "resistance of I/O pin when set as input" in the datasheet, but my guess is that it will be some sort of unintelligible Greek letter. If I got this value, I'd then have to compare to the datasheet of the MOS transistors to see what kind of current they need to turn on. Can anyone help me out on this? Of course, we could use a transistor type that requires far much more current to turn on so that we can be sure that "high impedance" won't turn either of them on. A bi-polar junction transistor would be suitable, e.g. a BC337 for n-channel and a BC327 for p-channel. The problem I see with this however is that you'll *always* get current flowing from: * Vcc * to the emitter of the p-channel * into the base of the p-channel * into the base of the n-channel * to ground This "phantom" current would mean that both transistors are always turned on. I think the only way of stopping this would be to put large resistors on the bases... but then we'd have to be very particular about what current we have flowing into the bases when the PIC pin is set as output. In my most recent project for college, I went with the BJT setup. It worked. Don't ask me how, but it worked. The theory of it tells me that both transistors should always have been turned on, but miraculously it worked. My only conclusion is that either: 1) I mixed up emitter and collector pins on the schematic 2) Somehow there wasn't enough current flowing to turn on both tranistors (but 5 V across two diodes should be more than enough current). -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist