Back to: Multiplier Event Luxembourg
Red (R), green (G), and blue (B) are the primary colours of light used to create digital images. LED colours are set using these colours of light, represented as an (R, G, B) tuple. Each component of the RGB tuple is set to a number between 0 and 255, indicating their intensity value. By adjusting the intensity levels of red, green, and blue, the LED produces different shades, creating a broad spectrum of colours.
The Circuit Playground Express board features a light sensor on the upper left side, near the eye symbol on the board.

This sensor can also function as a colour sensor, as demonstrated in the following section, or even as a pulse sensor (see the section Make it pulse). It detects ambient light and provides the corresponding light level reading. The light sensor has a spectral response similar to that of the human eye. The average indoor light level reading is around 300, with higher values indicating greater brightness.
To use the light sensor to read colour, you need to add the NeoPixel located close to the sensor, which is NeoPixel #1. The term “colour sensor” refers to the light sensor combined with NeoPixel #1.

When you perceive something as blue, it is because it is reflecting blue light from the entire spectrum. If you light up NeoPixel #1 with each primary colour of light and take a reading from each, you can determine how much of each colour was reflected and duplicate it on all the NeoPixels. The NeoPixels light up in the colour of the object held against the colour sensor. It is not a perfect system since NeoPixel cannot produce true primary colours, and the entity of NeoPixels will not reproduce every colour you try to match perfectly. The result still provides a close approximation.
The users can try holding up objects with bright colours in front of the Circuit Playground Express board’s colour sensor.