Example wiring for low-side switching of an RGB LED and Arduino test code for cross fading between colors.

This is a quick example for wiring up a common anode RGB LED using a low-side transistor to control each color pin. While you could connect each of the RGB color pins directly to an Arduino GPIO pin and control them directly, if the LED you're using requries more current that the Arduino pins can sink (~20mA advisable maximum), controlling them through transistors allows you to provide that extra current.


This project assumes you're using a common anode (+) RGB LED. Pretty much any NPN transistor will work for this project, but the current limiting resistor value indicated in the schematic is selected for a 2N2222. Appropriate values for your LED current limiting resistors may vary from what is indicated in the project. Because the positive supply for the LEDs is coming from the Arduino, you probably won't burn them out even if you had no current limiting resistors at all, but using them is a good habit to get into to avoid accidentally blowing up your LEDs.


The associated test code will fade your RGB LED from one color to another for maximum fanciness.