Lesson 2 – RGB LED Controller

Motivation

RGB LEDs are commonly used in stage lighting, mood lighting, outdoor lighting and home applications. Using the MSP430, we can create an adjustable LED lamp.

Background

A common-cathode RGB LED has 4 pins. R, G, B and ground. The MSP430 will be used to output a PWM waveform to vary the individual R, G and B components via current-limiting resistor. Using the GUI, the user can set a desired color by either clicking on a color wheel or by manually adjusting the R, G and B values. This allows for an enormous range of colors to be displayed.

Operation

A UART is used to communicate a 8-bit value (0-255 decimal) to the R, G and B LEDs. The MSP430 converts these values into an appropriate PWM waveform.

The MSP430 timer module A will be used to output PWM waveforms to control the R, G and B of the LED.

Timer_A0 and Timer_A1 are configured to output varying duty cycle PWM waveforms on P1.2 (red), P1.4 (green), and P1.5 (blue). See the wiring diagram below:

Figure 1 – Wiring diagram

The GUI

As mentioned previously, the color of the individual R, G and B LEDs can be configured by typing in the textbox or adjusting the slider. To get a unique color, the color wheel can be used.

Figure 2 – The GUI
Figure 3 – Code flowchart