Answers.Body: <p>The specs for the Lego education sensor can be found at
  <a href="https://assets.education.lego.com/v3/assets/blt293eea581807678a/blt62a78c227edef070/5f8801b9a302dc0d859a732b/techspecs_techniccolorsensor.pdf" rel="nofollow noreferrer">https://assets.education.lego.com/v3/assets/blt293eea581807678a/blt62a78c227edef070/5f8801b9a302dc0d859a732b/techspecs_techniccolorsensor.pdf</a></p>
  <p>I will also paste the info here:</p>
  <blockquote>
  <p><strong>Hardware name:</strong> Technic™ Color Sensor</p>
  <p><strong>Description:</strong> The sensor can detect color, reflectivity, or ambient light. The sensor can also be used as a light output.</p>
  <p><strong>Key features</strong></p>
  <ul>
  <li>Color sensing (RGB, HSV, and LEGO® colors)</li>
  <li>Reflectivity sensing (for line following)</li>
  <li>Ambient light sensing</li>
  <li>Emission of white light</li>
  <li>The sensor has a Technic build geometry that allows for versatile building and easy integration into models</li>
  </ul>
  <p><strong>Connector type:</strong> LEGO Power Functions 2.0 (LPF2) for connection to LEGO Smarthubs (i.e. LEGO Powered Up)</p>
  <p><strong>Wire length:</strong> 250 mm</p>
  <p><strong>Sensor sample rate:</strong> 100 Hz</p>
  <p><strong>Sensor input</strong></p>
  <p>Color sensing:</p>
  <ul>
  <li>Optimal reading distance: 16 mm (depending on object size, color, and surface)</li>
  <li>Output range:
  <ul>
  <li>No object</li>
  <li>White (LEGO:01; R:244, G:244, B:244)</li>
  <li>Blue (LEGO:23; R:30, G:90, B:168)</li>
  <li>Black (LEGO:26; R:0, G:0, B:0)</li>
  <li>Green (LEGO:28; R:0, G:133, B:43)</li>
  <li>Yellow (LEGO:24; R:250, G:200, B:10)</li>
  <li>Red (LEGO:21; R:180, G:0, B:0)</li>
  <li>Medium azur (LEGO:322; R:104, G:195, B226)</li>
  <li>Bright reddish violet (LEGO:124; R:144, G:31, B:118)</li>
  </ul>
  </li>
  </ul>
  <p>Reflectivity sensing:</p>
  <ul>
  <li>Optimal reading distance: 16 mm (depending on object size, color, and surface)</li>
  <li>Output range:
  <ul>
  <li>Non-reflective/nothing = 0%</li>
  <li>Very reflective= 100%</li>
  </ul>
  </li>
  </ul>
  <p>Ambient light sensing:</p>
  <ul>
  <li>Output range:
  <ul>
  <li>Dark = 0%</li>
  <li>Bright = 100%</li>
  </ul>
  </li>
  </ul>
  <p><strong>Sensor output</strong></p>
  <p>LED output:</p>
  <ul>
  <li>Color: white - temperature 4000K</li>
  <li>Controlled individually (3 LEDs in total)</li>
  <li>Cannot be used while sensor is in color/light sensing mode</li>
  <li>Output power: controllable from 0-100% increments of 1%</li>
  </ul>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-11-17T00:24:13.360Z
Answers.LastActivityDate: 2024-11-18T21:08:19.207Z
Answers.LastEditDate: 2024-11-18T21:08:19.207Z
Answers.UserDisplayName: Masked Marble
Answers.Body: <h3>Official Sources</h3>
  <p>The <a href="https://www.lego.com/en-us/product/color-distance-sensor-88007" rel="nofollow noreferrer">LEGO Shop page for the Color &amp; Distance Sensor (88007)</a> says:</p>
  <blockquote>
  <p>Detect 6 colors and objects within 5 to 10 cm range with this robot toy accessory for kids.</p>
  </blockquote>
  <p>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.</p>
  <p>A <a href="https://community.legoeducation.com/blogs/31/220" rel="nofollow noreferrer">LEGO Education blog post</a> has this to say about the SPIKE color sensor:</p>
  <pre><code>-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)
  </code></pre>
  <h3>3rd-pary resources</h3>
  <h4>Pybricks</h4>
  <p>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.</p>
  <p>This is discussed in detail at <a href="https://github.com/pybricks/support/issues/116" rel="nofollow noreferrer">https://github.com/pybricks/support/issues/116</a>.</p>
  <p>With some of the proposed changes, it is even possible to detect black vs. dark gray vs. light gray with both of these sensors.</p>
  <h4>Reverse engineering</h4>
  <p><a href="https://github.com/JorgePe/BOOSTreveng/blob/master/ColorDistanceSensor.md" rel="nofollow noreferrer">This page</a> on reverse engineering the BOOST Color Distance Sensor says:</p>
  <blockquote>
  <p>Color values are:</p>
  <ul>
  <li>BLACK 0x00</li>
  <li>BLUE 0x03</li>
  <li>GREEN 0x05 (Cyan or Turquoise in RGB LED)</li>
  <li>YELLOW 0x07</li>
  <li>RED 0x09</li>
  <li>WHITE 0x0A</li>
  </ul>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-15T10:34:12.100Z
Answers.Text: 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) ?
Answers.UserDisplayName: Michael Verschaeve
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-15T16:48:12.273Z
Answers.Text: 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.
Answers.UserDisplayName: David Lechner
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-14T18:43:15.207Z
Answers.LastActivityDate: 2023-02-17T17:49:47.527Z
Answers.LastEditDate: 2023-02-17T17:49:47.527Z
Answers.UserDisplayName: David Lechner
Body: <p>Lego currently offers two color sensors to use with Powered Up or robotic kits (Spike Prime, Spike Essential, Mindstorms robotic inventor):</p>
  <p><a href="https://www.lego.com/en-us/product/color-distance-sensor-88007" rel="noreferrer">https://www.lego.com/en-us/product/color-distance-sensor-88007</a>
  <a href="https://i.sstatic.net/BeX9m.png" rel="noreferrer"><img src="https://i.sstatic.net/BeX9m.png" alt="enter image description here" /></a>
  <a href="https://education.lego.com/en-us/products/lego-technic-color-sensor/45605" rel="noreferrer">https://education.lego.com/en-us/products/lego-technic-color-sensor/45605</a>
  <a href="https://i.sstatic.net/RtFj4.png" rel="noreferrer"><img src="https://i.sstatic.net/RtFj4.png" alt="enter image description here" /></a></p>
  <p>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.</p>
  
Tags: <mindstorms><powered-up><sensor-colour><robot-inventor><spike-prime>
Title: Lego colors that the powered up color sensors can detect
UserDisplayName: Michael Verschaeve
ThreadText: # Lego colors that the powered up color sensors can detect
  
  (Asked by: username_0 on 2023-02-14)
  
  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://i.sstatic.net/BeX9m.png)](https://i.sstatic.net/BeX9m.png)
  <https://education.lego.com/en-us/products/lego-technic-color-sensor/45605>
  [![enter image description here](https://i.sstatic.net/RtFj4.png)](https://i.sstatic.net/RtFj4.png)
  
  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.
  
  **Tags:** mindstorms, powered-up, sensor-colour, robot-inventor, spike-prime
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-02-14. Score: 10 | Accepted answer
  
  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
  
  > **Comments:**
  > **username_0**: 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) ?  
  > **username_2**: 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.  
  
  ---
  
  ### Answer by username_1 on 2024-11-17. Score: 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%
  
  
  ---
  
  