Two-pin RGB LED is driven by PWM. It means the duration of the PWM pulse defines the color of the LED. The transitions between colors should happen relatively quickly, in the order of microseconds. To control RGB LED with Arduino, you have to write a PWM value to a certain pin of Arduino. As the name PWM indicates, the duty cycle of the PWM pulse defines the color of the LED. A PWM value of 0 turns the LED off, while a PWM value of 255 turns the LED fully on. The duty cycle in between those values will gradually fade the LED between the colors. For example, if you set a PWM value of 120, the LED will be 50% on. In order to control the RGB LED, we need to write a value from 0-255 to PWM pin 9 and PWM pin 10.