So, if I have (say) a red/green bicolor LED and switch between the two colors faster than the eye can see (eg 250 Hz), what colors are perceived?
Can I use a RGB tricolor LED to mix any color output?
Have a look at https://en.wikipedia.org/wiki/RGB_color_spaces Depending on the wavelengths chosen for the red, green and blue LED you could not mix any color. Colors outside the defined color triangle could not be mixed. Each LED may have only a positive intensity. Colors outside the triangle would require at least one negative intensity and could not be mixed using the chosen wavelengths.
"The human eye with normal vision has three kinds of cone cells that sense light, having peaks of spectral sensitivity in short ("S", 420 nm – 440 nm), middle ("M", 530 nm – 540 nm), and long ("L", 560 nm – 580 nm) wavelengths."
If you use one or more LED with a wavelength far outside the ranges of the cone cells some colors could not be mixed, colors that would be mixable using a better selection of LED wavelengths. So if you use 430, 460 and 480 nm, you could not trigger the cone cells for red.
Roughly speaking, alternating between two LEDs at high rate looks exactly same as lighting them both up simultaneously - assuming the LEDs don't move so you won't see them alternating.
Just look at your computer monitor with some magnifying glass.
Red and green lights added together appears yellow. Zoom in to a yellow part of the screen and you will see red and green subpixels lit.
If you switch between red and green, it will appear some sort of yellow, depending on exact balance of the spectrum and intensity of red and green LEDs.
However, if the LED moves or you move your eyes rapidly, you can see it making a line which alternates between red and green. Even at 250 Hz. Just like watching movies with rapid movements on DLP projectors. Some toys with moving LEDs make this phenomenon very visible.
RGB LEDs allow reproducing any colour (within the limits of the relative LED spectrums and intensities obviously) including white with the correct balance of RGB intensities.
Typical addressable RGB LED has a built in PWM circuitry to drive the three individual LEDs with 8-bit resolution, thus allowing for 16 million colours like typical LCD screens.
Hit Amazon and get yourself a $15 LED strip kit (with LED strip typically 5m, RGB controller, remote, power supply). Throw it together and play with it.
(they show the LED spool making a rainbow; that is false advertising; with this type using 5050 LEDs the entire spool can only be one color at once. But it can be any color. "Individually addressible" LED strips do exist that can rainbow like that, but are not useful as a teaching tool to answer your question.)
Put an oscilloscope on the controller outputs and look at the signal. It's a square wave with varying duty cycle AKA "PWM dimming".
Now, disconnect the blue wire from the controller. Your LED strips will now only do red/green/amber and things in that spectrum. Those are the same colors you will get from your red/green bicolor LED if you sent PWM to it.
The trick with a 2-pin bicolor LED is your maximum duty cycle for R or G can't exceed 50% (or rather, can't sum to more than 100%).
And yup, the same thing works with a tricolor LED, though presumably that has four pins so you can go 100% duty cycle on each channel.
I do exactly this for front panel LEDs on my equipment at work. Running at 100Hz, I can create distinctly different red, orange, yellow and green states.
The catch is that you don't just need a fast switching frequency. If you want to create colours, you need to vary the percentage of time an LED is on - so if you want to be able to vary intensities with a resolution of 1%, you need to be updating your LED states at 10kHz.
Even with this though, you do have the problem that the individual red and green elements of a bicolour LED are fairly visible if you've got an LED with a clear housing, so you will tend to see two distinct red and green lights instead of one light of the combined colour. You either need an LED with a frosted housing or you need some kind of frosted element in the way.
That said though, mixing yellow from red and green LEDs is always unsatisfactory. We're used to seeing fairly warm yellows, whereas LEDs will always give you something more like a hazard-suit yellow. For stage lighting where this is important, better-quality lights often add separate amber LEDs to give a more convincing shade of yellow - these are denoted RGBA.
Mixing white from RGB has the same problem. We know the clarity we expect from white light, and RGB elements simply can't deliver it. So again, better-quality stage lights often add a separate white LED to do this properly, giving us RGBWA lights.