EV3ColorSensor#
-
class EV3ColorSensor#
Class to interact with the EV3 Color Sensor.
Initialisation & Setup
-
EV3ColorSensor::EV3ColorSensor(SensorPort port)#
Constructs an EV3ColorSensor object.
- Parameters:
port – The sensor port the color sensor is connected to.
-
bool EV3ColorSensor::begin()#
Initializes the EV3 Color Sensor.
- Returns:
True if the EV3 Color Sensor was successfully initialized, false otherwise.
-
void EV3ColorSensor::setMode(EV3ColorSensorMode mode)#
Sets the operating mode of the EV3 Color Sensor.
The operating modes supported are:
COL_CAL
RGB_RAW
REF_RAW
COL_COLOR
COL_AMBIENT
COL_REFLECT
- Parameters:
mode – The operating mode to set
-
int EV3ColorSensor::getReflection()#
Retrieves the reflected light sensor value.
- Returns:
reflected light sensor value.
-
int EV3ColorSensor::getAmbient()#
Retrieves the ambient light sensor value.
- Returns:
ambient light sensor value.
-
int EV3ColorSensor::getColor()#
Retrieves the detected color.
- Returns:
detected color as EV3ColorSensorColor enum. The colors supported are:
NONE = 0
COLOR_BLACK = 1
COLOR_BLUE = 2
COLOR_GREEN = 3
COLOR_YELLOW = 4
COLOR_RED = 5
COLOR_WHITE = 6
COLOR_BROWN = 7