The key here is that diodes (LEDs) have a voltage drop below which they
will not conduct..
Say you have a green and a red LED. The voltage drop for each might be
1.5 and 1.2 respectively. If you put both in series with a current
limiting resister at 5 volts they will both light, BUT if you put them
both in series with a current limiting resister and 2.5 volts neither
will light.
So:
Get the two LEDs, two diodes where the diodes have a 1.5v drop each, and
two resistors Hook them up in the following order:
+5v-------/\/\/\---|>|---|>|---+---|>|---|>|---/\/\/\--------Ground
where the plus (+) is the PIC pin controlling the LEDs. The diodes
and LEDs can be mixed, only make sure that one LED and one diode are
between the pic and ground and one LED and one diode between the pic and +5.
The combined voltage drop of all the diodes and LEDs (1.2+1.5+1.5+1.5)
is 5.7. This is greater than the supply voltage (5v) so when the pin is
tri-stated none of the diodes will conduct, so neither LED lights.
When the PIC pin is high, the diode and LED going to +5 will have no
current, since the voltage drop (2.7) is greater than the votlage (0),
while the diode and LED going to ground will have a full 5v across them,
and that LED will light. The reverse is true for when the pin is low.
I hope this helps!
-Adam
Jerome Knapp wrote:
{Quote hidden}> Im trying to connect two LEDs to a pic port pin so that one lights
>when the output is low, the other lights when the output is high, and they are
>both off when the pin is tri-stated as an input. The first two requirements are
>easily met in a lot of ways but I cannot figure out a simple way to get both
>leds off when the pin is put into a hiZ state. I am looking for a solution
>that uses just a few extra transistors and resistors - not something with
>PALs or OpAmps.
>
> I have spent a bit of time puzzling over this and I am overlooking
>something obvious or it is not as simple as it seems. I think it can be
>done using both a p-channel and n-channel mosfets.
>
> Does anyone have any simpler, more elegant ideas?
>
>Thanks,
>Jerome Knapp
>
>--
>
http://www.piclist.com hint: The list server can filter out subtopics
>(like ads or off topics) for you. See
http://www.piclist.com/#topics
>
>
>
>
>
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics