This block works for EV3 Robot!
The Get Color block allows you to sample the data from the robot's color sensor(s).
The Get Color block supports two different methods of color identification:
Get.ColorID
Used to identify colors, this method will return a different number value for each detected color.
The color IDs are as follows:
Color | ID |
Black | 1 |
Blue | 2 |
Green | 3 |
Yellow | 4 |
Red | 5 |
White | 6 |
Brown | 7 |
Watch the HUD closely and see how the color IDs change as the robot reaches different colored spots on the floor:
Note that the color sensor cannot identify every single color, and may stray when confronted with unassigned colors.
Get.Red
This method is used to measure the intensity of the reflected light. Since black absorbs light while white reflects it, the returned value can distinguish between bright and dark colors. Dark colors return values as low as 0, while bright colors can return values as high as 100. This makes the getRed method ideal for line following using Proportional or PID control algorithms.
You can also use the Wait Until Color block to pause the code until the robot detects a specific color or crosses a certain threshold.
In this example, the robot will drive forward for as long as the color sensor is over a bright surface:
The program will also print to the console the current light intensity value (0-100).
Comments
Please sign in to leave a comment.