5

Lego currently offers two color sensors to use with Powered Up or robotic kits (Spike Prime, Spike Essential, Mindstorms robotic inventor):

https://www.lego.com/en-us/product/color-distance-sensor-88007 enter image description here https://education.lego.com/en-us/products/lego-technic-color-sensor/45605 enter image description here

I'd like to find a reference online which lists the colors these sensors are calibrated to detect and if such a thing does not exist, perhaps we could create an unofficial reference here. I'm also interested to see a mapping of the colors to colors used in production of existing Lego elements, perhaps also the bricklink name / id.

1 Answer 1

9

Official Sources

The LEGO Shop page for the Color & Distance Sensor (88007) says:

Detect 6 colors and objects within 5 to 10 cm range with this robot toy accessory for kids.

Since this one is aimed at kids in the retail market, there isn't much in the way of official technical information on this sensor.

A LEGO Education blog post has this to say about the SPIKE color sensor:

-1 = No object 
0 = Black (LEGO:26; R:0, G:0, B:0)
1 = Magenta (LEGO:124; R:144, G:31, B:118)
3 = Blue (LEGO:23; R:30, G:90, B:168)
4 = Turquoise (LEGO:322; R:104, G:195, B226)
5 = Green (LEGO:28; R:0, G:133, B:43)
7 = Yellow (LEGO:24; R:250, G:200, B:10)
9 = Red (LEGO:21; R:180, G:0, B:0)
10 = White (LEGO:01; R:244, G:244, B:244)

3rd-pary resources

Pybricks

At Pybricks, we use the raw HSV values (or convert raw RGB to HSV if HSV is not available) to do better color detection instead of relying on the detection built into the sensor firmware.

This is discussed in detail at https://github.com/pybricks/support/issues/116.

With some of the proposed changes, it is even possible to detect black vs. dark gray vs. light gray with both of these sensors.

Reverse engineering

This page on reverse engineering the BOOST Color Distance Sensor says:

Color values are:

  • BLACK 0x00
  • BLUE 0x03
  • GREEN 0x05 (Cyan or Turquoise in RGB LED)
  • YELLOW 0x07
  • RED 0x09
  • WHITE 0x0A
2
  • From the discussion I gather that in pybricks there's a mapping of the HSV or RGB values detected on actual bricks to the list of colors I find in parameters.h. What I'm not clear on, does CYAN map to the medium azure found in boost and spike prime, or the dark turqoise (teal) found in robotic inventor ? MAGENTA maps to magenta as found in the spike prime? Does VIOLET map to anything (I hope to purple as found in older technic sets) ? Feb 15 at 10:34
  • 1
    In the Pybricks code, currently the colors are the same as what we use for emitting light and are not matched to any specific LEGO brick color. In the linked discussion and the related pull request, there is some discussion about whether it would be useful/more accurate to have brick colors separate from light colors, but no conclusions have been made yet. Since you can define your own colors and make a custom list of colors for the color sensor to detect, you can detect just about any color as long as you don't have two that are too similar. Feb 15 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.