Arduino sketch for my program

I followed this instruction, but I found that it doesnot work (the RGB LED is off).
So, instead of connecting the long leg of RGB LED to ground (-), I connect it to the 5V source (+). And, it works.
But, it does not work as expected. Then, I figure out that the Logic (HIGH/LOW) is somehow inverted, so I invert the logic in my program and it works as expected.
My question is why does that happen?

  • \$\begingroup\$ Probably the instruction used a common cathode LED, and you used a common anode LED. \$\endgroup\$ – Peter Bennett Jun 4 '17 at 6:18
  • \$\begingroup\$ @PeterBennett So, Arduino logic is only designed for common cathode? \$\endgroup\$ – Terry Smith Jun 4 '17 at 6:25
  • 1
    \$\begingroup\$ No. The particular example program you used was designed for common cathode. As you found out, the program can be easily changed to deal with common anode. \$\endgroup\$ – Peter Bennett Jun 4 '17 at 15:04

In a common cathode LED, the common lead goes to the ground. The three individual colours are taken high to turn them on. That's positive logic.

In a common anode LED, the common lead is the positive, so is taken to +5V. The individual colours must now be taken low to turn them on. That's negative logic. It's not a function of the Arduino, it's a function of the LED and its connection.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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