Color Sensor

../_images/ev3device-color.png
class ColorSensor(port)

LEGO® MINDSTORMS® EV3 Color Sensor.

Parameters:

port (Port) – Port to which the sensor is connected.

await color() Color

Measures the color of a surface.

Returns:

Color.BLACK, Color.BLUE, Color.GREEN, Color.YELLOW, Color.RED, Color.WHITE, Color.BROWN, or Color.NONE if no color is detected.

await ambient() int: %

Measures the ambient light intensity.

Returns:

Ambient light intensity, ranging from 0% (dark) to 100% (bright).

await reflection() int: %

Measures how much a surface reflects the light emitted by the sensor.

Returns:

Measured reflection, ranging from 0% (no reflection) to 100% (high reflection).

await rgb() tuple[int, int, int]

Measures the reflection of a surface using a red, green, and then a blue light.

Returns:

Tuple of reflections for red, green, and blue light, each ranging from 0.0% (no reflection) to 100.0% (high reflection).