Class EV3ColorSensor

    • Constructor Detail

      • EV3ColorSensor

        public EV3ColorSensor​(UARTPort port)
      • EV3ColorSensor

        public EV3ColorSensor​(Port port)
    • Method Detail

      • initModes

        protected void initModes()
      • getColorID

        public int getColorID()
        Return an enumerated constant that indicates the color detected. e.g. Color.BLUE
        Specified by:
        getColorID in interface ColorIdentifier
        Returns:
        An integer from the Color constants, such as Color.BLUE
      • setFloodlight

        public void setFloodlight​(boolean floodlight)
        Turns the default LED light on or off. If the sensor has more than one lamp color, this will control the red LED.
        Specified by:
        setFloodlight in interface LampController
        Parameters:
        floodlight - true to turn on lamp, false for off (ambient light only).
      • isFloodlightOn

        public boolean isFloodlightOn()
        Checks if the floodlight is currently on.
        Specified by:
        isFloodlightOn in interface LampController
        Returns:
        true if on, false if off.
      • getFloodlight

        public int getFloodlight()
        Returns the color of the floodlight, including Color.NONE.
        Specified by:
        getFloodlight in interface LampController
        Returns:
        An enumeration of the current color.
      • setFloodlight

        public boolean setFloodlight​(int color)
        Used to turn on or off the floodlight by color. If the sensor has multiple light colors, you can control which color is turned on or off. If the color does not exist, it does nothing and returns false. You can turn the floodlight off by using Color.NONE.
        Specified by:
        setFloodlight in interface LampController
        Parameters:
        color - Use Color enumeration constant to control lamp colors.
        Returns:
        True if lamp changed, false if lamp color doesn't exist for this sensor.
      • getColorIDMode

        public SensorMode getColorIDMode()
        EV3 color sensor, Color ID mode
        Measures the color ID of a surface. The sensor can identify 8 unique colors (NONE, BLACK, BLUE, GREEN, YELLOW, RED, WHITE, BROWN).

        Size and content of the sample
        The sample contains one element containing the ID (0-7) of the detected color.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders
      • getRedMode

        public SensorMode getRedMode()
        EV3 color sensor, Red mode
        Measures the level of reflected light from the sensors RED LED.

        Size and content of the sample
        The sample contains one element containing the intensity level (Normalized between 0 and 1) of reflected light.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders
      • getAmbientMode

        public SensorMode getAmbientMode()
        EV3 color sensor, Ambient mode
        Measures the level of ambient light while the sensors lights are off.

        Size and content of the sample
        The sample contains one element containing the intensity level (Normalized between 0 and 1) of ambient light.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders
      • getRGBMode

        public SensorMode getRGBMode()
        EV3 color sensor, RGB mode
        Measures the level of red, green and blue light when illuminated by a white light source..

        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.

        Returns:
        A sampleProvider See leJOS conventions for SampleProviders