vex.color_sensor package

VEX Color Sensor.

class vex.color_sensor.ColorHue(value)[source]

Bases: IntEnum

Color Hue.

ROBOT MESH PYTHON B:

Defined color hue values.

robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_color_hue.html

BLUE: int = 9
BLUE_GREEN: int = 8
BLUE_VIOLET: int = 10
GREEN: int = 7
NONE: int = 0
ORANGE: int = 3
RED: int = 1
RED_ORANGE: int = 2
RED_VIOLET: int = 12
VIOLET: int = 11
WHITE: int = 13
YELLOW: int = 5
YELLOW_GREEN: int = 6
YELLOW_ORANGE: int = 4
class vex.color_sensor.Colorsensor(index: Ports, is_grayscale: bool = False, proximity: float = 700)[source]

Bases: Device

VEX Color Sensor.

ROBOT MESH PYTHON B:

robotmesh.com/studio/content/docs/vexiq-python_b/html/classvex_1_1_colorsensor.html

colorname12() int[source]

Return one of 12 colors or NONE.

ROBOT MESH PYTHON B:

Get the name of the detected color.

Returns: enum value of the closest color detected out of 12 possible values of ColorType (or NONE).

colorname3() int[source]

Return one of RED, GREEN and BLUE.

ROBOT MESH PYTHON B:

Get the name of the detected color.

Returns: enum value for the closest color detected out of ColorHue.RED, GREEN or BLUE (or NONE).

grayscale(raw: bool = False) int[source]

Return grayscale value.

ROBOT MESH PYTHON B:

Get the grayscale value detected by the color sensor.

Parameters: - raw: if True, raw value will be returned, otherwise a percentage

Returns: integer that represents the detected grayscale value (percentage 0-100 or raw 0-1024).

led(state: bool)[source]

Set LED state.

ROBOT MESH PYTHON B:

Turn the led on the color sensor on or off.

Parameters: - state: if True, LED will be turned on

near() bool[source]

Check if there is a nearly object.

ROBOT MESH PYTHON B:

Check to see if an object is detected by the color sensor.

Returns: True if an object has been detected, False otherwise

set_proximity_threshold(proximity: float = 700)[source]

Set threshold for proximity.

ROBOT MESH PYTHON B:

Set the near threshold setting.

Parameters: - proximity: threshold (higher is closer) (default 700)