ColorSensor
Smart CarMeasures how much red, green and blue light comes back from a surface. A small white lamp lights the surface, and filters in front of the sensor sort the colours.
How you reach it
Section titled “How you reach it”The ColorSensor class is reached through this attribute of robot.
robot.color_sensor
Section titled “robot.color_sensor”Can be None.
All the attributes of robot are in its table. Read Attributes that can be None to see when a part is None.
Methods
Section titled “Methods”read()
Section titled “read()”Measures now: (red, green, blue, clear) as raw counts from 0 to 65535.
read() -> Tuple[int, int, int, int]Used in examples: Sensor check
is_color(color, reading, tolerance)
Section titled “is_color(color, reading, tolerance)”True when red, green and blue of reading (a new one if None) are each within tolerance raw counts of color, an (r, g, b) tuple.
is_color(color, reading=None, tolerance: int) -> boolYou can leave out tolerance.
Used in examples: Sensor check
print_reading()
Section titled “print_reading()”Measures now and prints the red, green and blue raw counts.
print_reading()