With an RGB LED you can produce almost any color. How is this possible with just one single LED?
How do RGB LEDs work?
In fact, an RGB LED is a combination of 3 LEDs in just one package:
How to create different colors?
You can create one of those three colors – red, green or blue – by activating just one LED.
For example, if you want to produce blue, you activate the blue LED and turn off the other two.
To produce other colors, you can combine the three colors in different intensities. To generate different colors you can use PWM to adjust the brightness of each LED.
As the LEDs are very close to each other, we can only see the final colors result rather than the three colors individually.
To have an idea on how to combine the colors, take a look at the following chart. This is the simplest color mixing chart, there are more complex color charts on the web.