I have a tri-colour LED which consists internally of two LED's that have a common cathode. The device has 3 pins (two anodes and one cathode).
Using one microcontroller pin, I want to light the LED either red, green or off. The microcontroller's pin states are intended to be as follows: High = Light Red Low = Light Green Set as input = Light Nothing
First thing I'll do is put a 200 ohm resistor on the cathode of the device, and this resistor will lead directly to ground.
Taking the signal coming from the microcontroller pin, I'll split it into two branches:
- The first branch will go directly to the Red anode.
- The second branch will go to the gate of a PMOS transistor. The source of the PMOS will be connected to Vcc, and the drain will go to the Green anode.
The idea is: When the microcontroller pin is high, the Green will light on its own. When the microcontroller pin is low, the Red will light on its own.
Now I think I'll have a problem when I set the micrcontroller pin to high impedence, reason being that I don't know if the PMOS transistor will be turned on. Assuming that the PMOS transistor *would* be turned on, I could put a pull-up resistor on the gate of the PMOS transistor. I would want this pull-up resistor to have as high a value as possible because I don't want much current flowing from Vcc thru the pull-up resistor into the Red anode. The problem though is that I don't want the resistor value to be *too* high because then it might not do its job of pulling up the voltage at the PMOS's gate.
So I have two questions:
1) What would be a suitable PMOS transistor to use? My Vcc is 5 V and the current I want to pass is about 20 mA. (Also, I don't need one of those 4-pin transistors because my source will always be connected to Vcc). 2) Do I need a pull-up resistor, and if so what value should I choose for it? Remember I'd like it as high as possible so that it allows negligible current to flow into the Red anode.I know it might sound like I'm just firing out questions and expecting answers but the thing is I don't know how else to get these answers other than by asking people who have experience.
My microcontroller is the PIC16F684. If you need to know the impedence or whatever of the pins then let me know and I'll check the datasheet.
(By the way, my original design used a PNP bi-polar transistor instead of a PMOS transistor, but the problem with this was that a non- negligible current was flowing from Vcc, to the emitter, to the base and into the Red anode, and thus the Red was lighting up dimly.)