#Robotics Identifying Silver with Lego Spike Prime

In a number of my articles I have mentioned that you must enable “More Sensors” and use the Raw Red value to differentiate between white and silver. This is because the generic Reflected Light reading does not provide values that can safely tell the difference between white and silver.
This article explains how to enable “More Sensors” in the Spike software.
The issue with the Reflected Light reading block in the Spike software (using Word Blocks, Scratch Style) is that it reads 100% for silver and a value very close to 100% for white. There is not enough difference between the two values to reliably identify silver. This is because the Reflect Light reading has been calibrated to provide a value between black as 0% and white as 100%. Silver reflects even more light than white as so just hits the maximum 100%.
Enabling “More Sensors” allows us to access the Raw RGB (Red, Green, Blue) values from the sensor with a value from 0 and 1024. Using this block with Red, white will read a value of 800-900 when silver usually reads more than 1000. Now we have enough difference to reliably detect silver.
We can also use the Raw RGB values to detect colours more reliably (including non Lego colours) by converting the RGB (Red, Green, Blue) to HSI (Hue, Saturation, Intensity). The Hue value provides the degrees on a colour wheel, see this article for details of how to use this method:
Accessing More Sensors
To access this functionality, in the Spike Prime software on the bottom left is the Show Block Extensions icon.
Click on this icon and enable More Sensors. More Motors and More Movement can also be useful.
Click the X at top right to close.
Now on the left side at the bottom of the block list you will find More Sensors.
Reading the Raw Red value will give a big difference between white and silver that you cannot see with the generic Reflected Light value.
More Information
For more information on robotics, check out the following links:
- David’s Robotics Portal
- #Robotics Better Colour Detection by Converting RGB to HSI Values
- #Robotics Programming a Spike Prime Line Following Robot – Part 3
- #Robotics Programming a Spike Prime Wall Following Robot
Hope this information is useful.
David
This article was originally posted on https://www.winthropdc.com/blog.


