This block works for EV3 and Ruby Robot!
The Get Color block allows you to sample the data from the robot's color sensors, which can be configured to point in different directions: straight ahead, facing the sides, or even facing the ground (allowing the robot to identify lines or follow routes drawn on the floor).
The color sensor can distinguish between nine different colors, identified as string values:
"Black" , "White" , "Red" , "Yellow" , "Green" , "Cyan" , "Blue" , "Magenta" , "Brown" .
Note: the string values must be capitalized. If we use "green", the color sensor would not respond!
When in Reflection Value mode, the color sensor emits a beam of light and measures the intensity of the light reflected back to it in numerical values between 0 (black) and 100 (white) .
This makes the Color Sensor get Reflection Value method ideal for line following using Proportional Control, as it allows for a wide range of values and thus finer control.
Both Color Name and Reflection Value data is displayed in the HUD: