Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Inverting pin signal for bi-color led

  1. #1

    Inverting pin signal for bi-color led

    I'm sure this is documented somewhere, but I can't find it...

    Looking at picking up a bi-color led like this:

    https://www.mouser.com/ds/2/26/Apem_...Q6-1158530.pdf

    The color is changed by reversing the polarity of the supply voltage.

    Clueless as to how to implement this. AnalogWrite() does not accept negative value, AFAIK.

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,598
    With a 150R current limiter resistor between 2 GPIO pins. Drive one high, the second low (always with digitalWrite()) = one color. Drive the first low, the second high = other color. Both high or both low = LED off.

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,598
    It was documented in the electronics class in secondary school...

  4. #4
    Senior Member Wozzy's Avatar
    Join Date
    Jan 2013
    Location
    Philadelphia, Pennsylvania USA
    Posts
    354
    You can also use the method described in THIS POST to drive your Bicolor LED, from only a single pin.
    This can give you Red Green or Yellow.

    EDIT: Actually, Never Mind... this won't work because you can't tie in between the two LEDs on a two pin device.
    Theremingenieur's method is the way to go. Note that you can also get yellow by toggling between the two states very rapidly.

  5. #5
    thanks for your response.

    Must stop nodding off in class....

  6. #6
    Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    96
    Surry to ressurect this thread, but has anyone tried this with PWM?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •