A common-cathode RGB LED has a total of four pins. One of the pins is the cathode which must be connected to ground and the others each control a color. The pinout shown below is for a typical RGB LED. Notice that each of the pins is a slightly different length; the cathode is the longest.
Since there are three colors, controlling a common-cathode RGB LED with an Arduino requires three digital output pins (and three current limiting resistors). You could turn these pins off and on one at a time using digitalWrite()
commands. You could also use a byte (of which one bit controls each of the colors so five bits would be unused) and a bit-mask. See this post for more details. This would result in more compact code.
When lights of different colors are combined, new colors result. But unlike pigment mixing, which is subtractive color mixing, light mixing results in additive color mixing. Red and green makes yellow, red and blue makes magenta, and green and blue makes cyan. If red, green, and blue are simultaneously turned on, white light is produced. In order to obtain more fine grained control over the color produced by an RGB LED, you can use PWM and analogWrite()
(see this post for more details).