6

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.

2 Answers 2

10

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) ? Commented Feb 15, 2023 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. Commented Feb 15, 2023 at 16:48
4

The specs for the Lego education sensor can be found at https://assets.education.lego.com/v3/assets/blt293eea581807678a/blt62a78c227edef070/5f8801b9a302dc0d859a732b/techspecs_techniccolorsensor.pdf

I will also paste the info here:

Hardware name: Technic™ Color Sensor

Description: The sensor can detect color, reflectivity, or ambient light. The sensor can also be used as a light output.

Key features

  • Color sensing (RGB, HSV, and LEGO® colors)
  • Reflectivity sensing (for line following)
  • Ambient light sensing
  • Emission of white light
  • The sensor has a Technic build geometry that allows for versatile building and easy integration into models

Connector type: LEGO Power Functions 2.0 (LPF2) for connection to LEGO Smarthubs (i.e. LEGO Powered Up)

Wire length: 250 mm

Sensor sample rate: 100 Hz

Sensor input

Color sensing:

  • Optimal reading distance: 16 mm (depending on object size, color, and surface)
  • Output range:
    • No object
    • White (LEGO:01; R:244, G:244, B:244)
    • Blue (LEGO:23; R:30, G:90, B:168)
    • Black (LEGO:26; R:0, G:0, B:0)
    • Green (LEGO:28; R:0, G:133, B:43)
    • Yellow (LEGO:24; R:250, G:200, B:10)
    • Red (LEGO:21; R:180, G:0, B:0)
    • Medium azur (LEGO:322; R:104, G:195, B226)
    • Bright reddish violet (LEGO:124; R:144, G:31, B:118)

Reflectivity sensing:

  • Optimal reading distance: 16 mm (depending on object size, color, and surface)
  • Output range:
    • Non-reflective/nothing = 0%
    • Very reflective= 100%

Ambient light sensing:

  • Output range:
    • Dark = 0%
    • Bright = 100%

Sensor output

LED output:

  • Color: white - temperature 4000K
  • Controlled individually (3 LEDs in total)
  • Cannot be used while sensor is in color/light sensing mode
  • Output power: controllable from 0-100% increments of 1%

Your Answer

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

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