Follow-Up to Driving a Bicolor LED from a Single Output Pin

Within mere hours of posting yesterday’s entry about driving a bicolor LED from a single pin using the trick of turning the port into an input to make it tristate, “Mazzoo” posted an excellent comment, including this very insightful statement:

tristating or setting a controller pin as input, and leave it floating or (even worse) setting it to Vcc/2 is a reliable way to destroy the input gate.

That’s a very good point, and one that I hadn’t been thinking about (but hope I would have considered sooner or later).

Digital logic inputs depend on being high or low, and don’t deal well with inputs in the “dead band” in between. With many digital inputs, a voltage in the dead band puts the input transistors into their linear regions, which causes them to carry excessive current and overheat quickly. Deliberately putting digital inputs into the dead band for long periods of time would be a very bad idea.

Thus, to use this method for driving a bicolor LED, not only does the pin need to be changed to an input so it tristates, but it needs to be an A/D pin set to analog mode, so it doesn’t mind seeing a voltage in the dead band.

As I’ve described before, having a PIC pin set as an analog input changes the PORTX register from a read/write register to a write-only register, and you have to read the values from LATX, which messes up the LogoChip’s clearbit / setbit / testbit commands. But I’ll just have to work around that by using LATX instead of PORTX, because I can’t leave the pin floating in digital input mode.

Thanks, Mazzoo!

July 4:

It should also be safe to use tristating on a pin in digital input mode with a Schmitt trigger — pin A4 and all of port C. Unfortunately for me, the LogoChip’s design already uses most of port C, and I really wouldn’t have enough pins available to drive the four bicolor LEDs that I want to use in this project. So analog inputs it is.

Leave a Reply