Sorry I am a newbie at this but I have reviewed 3 books and none of them
explain how to control the ground. They only explain how to turn on and off
the power. I have a simple BI-COLOR LED from radioshack (#276-207) and to
change between the colors I have to turn on and off or switch the ground
between the PIN 1 and 3. I am using the normal "starter" PICs 16F84A.

Hi-
You can wire pin2 to 5V, and pins 1&3 to two different output pins on the PIC.
If you write a zero to the pin connected to pin1, then current will flow fron
teh 5V to the PIC pin into ground inside the PIC, likewise the other pin. If
you make them both zero, you will turn on both colours. If a pin is a 1, then
both sides of the LED are at 5V, so no current flows, and the LED is off.
David

> Sorry I am a newbie at this but I have reviewed 3 books and none of them
> explain how to control the ground. They only explain how to turn on and off
> the power. I have a simple BI-COLOR LED from radioshack (#276-207) and to
> change between the colors I have to turn on and off or switch the ground
> between the PIN 1 and 3. I am using the normal "starter" PICs 16F84A.
>
> Thanks in advance for any advice.
>
> Rob
>
> --
> http://www.piclist.com hint: The PICList is archived three different
> ways. See http://www.piclist.com/#archives for details.

If you go to Radioshack's site (http://www.radioshack.com) and
search for 276207 you'll find the LED's page. It doesn't
actually show that LED, but the "Schematic" link takes
you to a page which has a very scruffy gif on it. As far as I can
make out, this is the wiring of the LED. It's a common anode
type which, as David says, you wire the middle pin (2) to
5V and then 1 and 3 go to a PIC pin each through a resistor
each. I've just wired up some common cathode bi-colours
and found that the red needed 680 ohms in series to match
brightness with the green, which has 390 ohms in series. As
yours is a common anode type, the PIC pins need to sink
the current (ie you send the pin low to complete the circuit)
whereas my common cathode types need the middle pin
at 0V and the PIC pins go high to source the LED current.

PICs (and many digital ICs) can sink more current than they
can source, and a load such as LEDs works better on the
"high" side of the PIC, that is, between the PIC pin and 5V

If it is a two pin bicolor LED: connect a resistor in series with one of the pins, then the loose ends of both th eresistor and LED to one PIC pin each. To torn on one color hold one pin highn the other low. For the other color switch high/low.

If it is a three pin bicolor/tricolor LED: connect the middele pin to GND. The other pins to one PIC pin each whith series resistor. To turn on one color hold one pin highn the other low. For the other color switch high/low. For a mix of both hold both high.

>Sorry I am a newbie at this but I have reviewed 3 books and none of them
>explain how to control the ground. They only explain how to turn on and off
>the power. I have a simple BI-COLOR LED from radioshack (#276-207) and to
>change between the colors I have to turn on and off or switch the ground
>between the PIN 1 and 3. I am using the normal "starter" PICs 16F84A.
>
>Thanks in advance for any advice.
>
>Rob
>
>--
>http://www.piclist.com hint: The PICList is archived three different
>ways. See http://www.piclist.com/#archives for details.

Sorry to state the obvious but don't forget to
place a resistor on either of the two colour pins or one on the
ground leg

Hi-
You can wire pin2 to 5V, and pins 1&3 to two different output pins on the PIC.
If you write a zero to the pin connected to pin1, then current will flow fron
teh 5V to the PIC pin into ground inside the PIC, likewise the other pin. If
you make them both zero, you will turn on both colours. If a pin is a 1, then
both sides of the LED are at 5V, so no current flows, and the LED is off.
David

Another trick on 2 pin bi-color LEDs is to put a couple resistors in series (I use about 240 ohms) between +5V and ground. Put the LED between the junction of the resistors and the PIC pin. Tristate the pin to turn the LED off (note that PIC power dissipation will go up a bit since the pin is held at half Vcc by LED leakage current). To make the LED glow one color, set the pin low. The other color, set the pin high. This trick can save you one PIC pin.

Hej Harold Hallikainen. Tack för ditt meddelande 15:09 2002-09-06 enligt nedan:
>Another trick on 2 pin bi-color LEDs is to put a couple resistors in series (I use about 240 ohms) between +5V and ground. Put the LED between the junction of the resistors and the PIC pin. Tristate the pin to turn the LED off (note that PIC power dissipation will go up a bit since the pin is held at half Vcc by LED leakage current).

The bigger power waste is that current also flows in the resistor that is parallel to th elit diode. And when both are off, current flows in both resistors.

One method is to replace both resistors with zeners, and add one current limiting resistor in series with the led. (if we don´t dare to rely on totla series resistnace of PIC+LED+zener, which i don´t).

> To make the LED glow one color, set the pin low. The other color, set the pin high. This trick can save you one PIC pin.
>
>Harold
>
>
>
>
>________________________________________________________________
>GET INTERNET ACCESS FROM JUNO!
>Juno offers FREE or PREMIUM Internet access for less!
>Join Juno today! For your FREE software, visit:
>dl.http://www.juno.com/get/web/.
>
>--
>http://www.piclist.com hint: The PICList is archived three different
>ways. See http://www.piclist.com/#archives for details.

The two zener approach is clever, but a little more expensive. It's also
true that the power dissipation in the voltage divider is higher than
that in the PIC due to leakage current when the input is trisated.
Another trick (but, again, a bit more expensive) is to use a "rail
splitter" virtual ground (like
focus.ti.com/docs/prod/productfolder.jhtml?genericPartNumber=TLE24
26). This is pretty much a voltage divider followed by an op-amp voltage
follower. But, again, cost is higher.
So, there are some neat tricks out there!

> Hej Harold Hallikainen. Tack fvr ditt meddelande 15:09 2002-09-06
> enligt nedan:
> >Another trick on 2 pin bi-color LEDs is to put a couple resistors
> in series (I use about 240 ohms) between +5V and ground. Put the LED
> between the junction of the resistors and the PIC pin. Tristate the
> pin to turn the LED off (note that PIC power dissipation will go up
> a bit since the pin is held at half Vcc by LED leakage current).
>
> The bigger power waste is that current also flows in the resistor
> that is parallel to th elit diode. And when both are off, current
> flows in both resistors.
>
> One method is to replace both resistors with zeners, and add one
> current limiting resistor in series with the led. (if we don4t dare
> to rely on totla series resistnace of PIC+LED+zener, which i don4t).
>

David,
Thanks I did not know that the PICs would handle ground and current
for me. I tried what you stated but one of the colors always stayed on. But
I ended up using pin 0 --> 2 and connecting all 3 of the BI-Color LED pins
to the PICs. pin 0 turns on red, pin 1 is power, and pin 2 is green. If I
want to turn off the light all I have to do is LOW the pin 1.

I could not figure out what you were asking me to do when you say write a
zero to the pin.

The down side of this is that it eats up 3 pins. Where as I could do the
same thing with 2 pin and 2 LEDs rather that just a BI-Color 3 pin LED.