lejos.nxt
Class ColorSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.ColorSensor
All Implemented Interfaces:
SensorConstants

public class ColorSensor
extends I2CSensor

HiTechnic color sensor.
www.hitechnic.com


Field Summary
 
Fields inherited from interface lejos.nxt.SensorConstants
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_CUSTOM, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE
 
Constructor Summary
ColorSensor(lejos.nxt.I2CPort port)
           
 
Method Summary
 int getBlue()
          Returns the blue saturation of the color.
 int getColorNumber()
          Returns the color index detected by the sensor.
 int getGreen()
          Returns the green saturation of the color.
 int getRed()
          Returns the red saturation of the color.
 
Methods inherited from class lejos.nxt.I2CSensor
getData, getProductID, getSensorType, getVersion, sendData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

ColorSensor

public ColorSensor(lejos.nxt.I2CPort port)
Method Detail

getColorNumber

public int getColorNumber()
Returns the color index detected by the sensor.

Returns:
Color index.
  • 0 = black
  • 1 = violet
  • 2 = purple
  • 3 = blue
  • 4 = green
  • 5 = lime
  • 6 = yellow
  • 7 = orange
  • 8 = red
  • 9 = crimson
  • 10 = magenta
  • 11 to 16 = pastels
  • 17 = white

  • getRed

    public int getRed()
    Returns the red saturation of the color.

    Returns:
    red value (0 to 255).

    getGreen

    public int getGreen()
    Returns the green saturation of the color.

    Returns:
    green value (0 to 255).

    getBlue

    public int getBlue()
    Returns the blue saturation of the color.

    Returns:
    blue value (0 to 255).