VEX IQ Python API
Public Member Functions | List of all members
vex.Colorsensor Class Reference
Inheritance diagram for vex.Colorsensor:
vex.Device

Public Member Functions

def __init__ (self, index, is_grayscale=False, proximity=700)
 
def colorname3 (self)
 Gets the name of the detected color. More...
 
def colorname12 (self)
 Gets the name of the detected color. More...
 
def grayscale (self, raw=False)
 Gets the grayscale value detected by the color sensor. More...
 
def near (self)
 Check to see if an object is detected by the color sensor. More...
 
def set_proximity_threshold (self, proximity)
 Set the near threshold setting. More...
 
def led (self, state)
 Turns the led on the color sensor on or off. More...
 

Detailed Description

 @brief Creates a new color sensor object on the port specified in the parameter.
 @param index The port index (zero-based)
 @param is_grayscale Whether grayscale mode (LED on), default false
 @param proximity threshold (default 700)

Constructor & Destructor Documentation

◆ __init__()

def vex.Colorsensor.__init__ (   self,
  index,
  is_grayscale = False,
  proximity = 700 
)

Member Function Documentation

◆ colorname3()

def vex.Colorsensor.colorname3 (   self)

Gets the name of the detected color.

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

◆ colorname12()

def vex.Colorsensor.colorname12 (   self)

Gets the name of the detected color.

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

◆ grayscale()

def vex.Colorsensor.grayscale (   self,
  raw = False 
)

Gets the grayscale value detected by the color sensor.

Returns
integer that represents the detected grayscale value (percentage 0-100 or raw 0-1024).
Parameters
rawif True, raw value will be returned, otherwise a percentage

◆ near()

def vex.Colorsensor.near (   self)

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

def vex.Colorsensor.set_proximity_threshold (   self,
  proximity 
)

Set the near threshold setting.

Parameters
proximitythreshold (higher is closer) (default 700)

◆ led()

def vex.Colorsensor.led (   self,
  state 
)

Turns the led on the color sensor on or off.

Parameters
stateif True, LED will be turned on