public class EV3ColorSensor extends UARTSensor implements LampController, ColorIdentifier
| Supported modes | |||
|---|---|---|---|
| Mode name | Description | unit(s) | Getter |
| Color ID | Measures the color ID of a surface | Color ID | getColorIDMode() |
| Red | Measures the intensity of a reflected red light | N/A, Normalized to (0-1) | getRedMode() |
| RGB | Measures the RGB color of a surface | N/A, Normalized to (0-1) | getRGBMode() |
| Ambient | Measures the ambient light level | N/A, Normalized to (0-1) | getAmbientMode() |
Sensor configuration
The flood light of the sensor can be put on or off using the setFloodlight methods.
See Sensor Product page
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
| Modifier and Type | Field and Description |
|---|---|
protected static int |
COL_AMBIENT |
protected static int |
COL_CAL |
protected static int |
COL_COLOR |
protected static int |
COL_REFLECT |
protected static int |
COL_REFRAW |
protected static int |
COL_RESET |
protected static int |
COL_RGBRAW |
protected static int[] |
colorMap |
protected static int[] |
lightColor |
protected short[] |
raw |
protected static int |
SWITCH_DELAY |
currentMode, portmodes| Constructor and Description |
|---|
EV3ColorSensor(Port port) |
EV3ColorSensor(UARTPort port) |
| Modifier and Type | Method and Description |
|---|---|
SensorMode |
getAmbientMode()
EV3 color sensor, Ambient mode
Measures the level of ambient light while the sensors lights are off. |
int |
getColorID()
Return an enumerated constant that indicates the color detected.
|
SensorMode |
getColorIDMode()
EV3 color sensor, Color ID mode
Measures the color ID of a surface. |
int |
getFloodlight()
Returns the color of the floodlight, including Color.NONE.
|
SensorMode |
getRedMode()
EV3 color sensor, Red mode
Measures the level of reflected light from the sensors RED LED. |
SensorMode |
getRGBMode()
EV3 color sensor, RGB mode
Measures the level of red, green and blue light when illuminated by a white light source.. |
protected void |
initModes() |
boolean |
isFloodlightOn()
Checks if the floodlight is currently on.
|
void |
setFloodlight(boolean floodlight)
Turns the default LED light on or off.
|
boolean |
setFloodlight(int color)
Used to turn on or off the floodlight by color.
|
switchModefetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModesclose, releaseOnCloseprotected static int[] colorMap
protected static final int SWITCH_DELAY
protected static final int COL_RESET
protected static final int COL_REFLECT
protected static final int COL_AMBIENT
protected static final int COL_COLOR
protected static final int COL_REFRAW
protected static final int COL_RGBRAW
protected static final int COL_CAL
protected static final int[] lightColor
protected short[] raw
public EV3ColorSensor(UARTPort port)
public EV3ColorSensor(Port port)
protected void initModes()
public int getColorID()
getColorID in interface ColorIdentifierpublic void setFloodlight(boolean floodlight)
setFloodlight in interface LampControllerfloodlight - true to turn on lamp, false for off (ambient light only).public boolean isFloodlightOn()
isFloodlightOn in interface LampControllerpublic int getFloodlight()
getFloodlight in interface LampControllerpublic boolean setFloodlight(int color)
setFloodlight in interface LampControllercolor - Use Color enumeration constant to control lamp colors.public SensorMode getColorIDMode()
Size and content of the sample
The sample contains one element containing the ID (0-7) of the detected color.
leJOS conventions for
SampleProviderspublic SensorMode getRedMode()
Size and content of the sample
The sample contains one element containing the intensity level (Normalized between 0 and 1) of reflected light.
leJOS conventions for
SampleProviderspublic SensorMode getAmbientMode()
Size and content of the sample
The sample contains one element containing the intensity level (Normalized between 0 and 1) of ambient light.
leJOS conventions for
SampleProviderspublic SensorMode getRGBMode()
Size and content of the sample
The sample contains 3 elements containing the intensity level (Normalized between 0 and 1) of red, green and blue light respectivily.
leJOS conventions for
SampleProviders