Skip to content

Search the documentation

Kit
Firmware

ColorSensor

Smart Car

Measures 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.

The ColorSensor class is reached through this attribute of robot.

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.

Measures now: (red, green, blue, clear) as raw counts from 0 to 65535.

read() -> Tuple[int, int, int, int]

Used in examples: Sensor check

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) -> bool

You can leave out tolerance.

Used in examples: Sensor check

Measures now and prints the red, green and blue raw counts.

print_reading()