2

My LED only works when it's plugged in "backwards" like the following example:

https://pi4j.com/1.2/images/gpio-control-example.png

My understanding is that the longer pin on the LED should go direct to GND, however when I connect it that way, it no longer illuminates. Why is this backwards? I also cant get my RGB LED to illuminate more than one color. Putting the longest pin to GND doesn't work. It works when the longest pin is going to the 3.3v terminal and one of the other pins is going to GND.

Any advice?

enter image description here

0

1 Answer 1

3

For the regular LED we will need to see photos to know what you mean by backward and forward. Normaly, the longer leg is positive (anode) and the shorter is negative (cathode). Also, the cathode is often identified by a flat edge around the bottom of the plastic housing. If it only lights up when installed what you call backward, either the LED is wrong or your mental model is. It is hard to tell from the picture but it looks like the longer leg is connected to VCC. I would start here for blinking a single LED

RGB LED's come in common anode (common power) and common cathode (common ground) varieties. From your description, you have a common anode RGB LED. To get multiple colors you will need to connect the long pin 3.3volts and the other three pins to ground or 3 GPIO pins. The other 3 pins are the red green and blue pins. Try connecting the LED to 3.3V and one at a time connecting the other three pins to ground.

A search for Raspberry Pi and RGB LED should give you several tutorials to follow, like this one that covers both common anode and common cathode RGB LED's. You may want to look at pulse width modulation (PMW) to fade a single LED before trying to control your RGB color.

1
  • 1
    Ah that makes sense now. I connected the long pin to 3.3V and the other pins to GPIO and just changed my logic to set them to LOW instead of HIGH and now everything is working. Thanks!
    – Brad
    Dec 11, 2019 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.