Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lejos.nxt
Class LightSensor

    java.lang.Object
      lejos.nxt.LightSensor

All Implemented Interfaces:
  SensorConstants

    public class LightSensor

extends Object
implements SensorConstants

Abstraction for a NXT light sensor. The light sensor can be calibrated to low and high values.

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
`LightSensor(lejos.nxt.ADSensorPort port)` Create a light sensor object attached to the specified port.
`LightSensor(lejos.nxt.ADSensorPort port, boolean floodlight)` Create a light sensor object attached to the specified port, and sets floodlighting on or off.

Method Summary
`void` | `calibrateHigh()` call this method whtn the light sensor is reading the high value - used by reaeValue
`void` | `calibrateLow()` call this method when the light sensor is reading the low value - used by readValue
`int` | `readNormalizedValue()` Read the current sensor normalized value.
`int` | `readValue()` Read the current sensor value.
`void` | `setFloodlight(boolean floodlight)` Set floodlighting on or off.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait`

Constructor Detail

### LightSensor

    public LightSensor(lejos.nxt.ADSensorPort port)

  Create a light sensor object attached to the specified port. The sensor will be set to floodlit mode, i.e. the LED will be turned on.

  Parameters:
    `port` - port, e.g. Port.S1

### LightSensor

    public LightSensor(lejos.nxt.ADSensorPort port,
                       boolean floodlight)

  Create a light sensor object attached to the specified port, and sets floodlighting on or off.

  Parameters:
    `port` - port, e.g. Port.S1
    `floodlight` - true to set floodit mode, false for ambient light.

Method Detail

### setFloodlight

    public void setFloodlight(boolean floodlight)

  Set floodlighting on or off.

  Parameters:
    `floodlight` - true to set floodit mode, false for ambient light.

### readValue

    public int readValue()

  Read the current sensor value. Use calibrateLow() to set the zero level, and calibrateHigh to set the 100 level.

  Returns:
    Value as a percentage of difference between the low and high calibration values.

### readNormalizedValue

    public int readNormalizedValue()

  Read the current sensor normalized value. Allows more accuracy than readValue(). For LEGO sensor, values typically range from 145 (dark) to 890 (sunlight).

  Returns:
    Value as raw normalized (0 to 1023)

### calibrateLow

    public void calibrateLow()

  call this method when the light sensor is reading the low value - used by readValue

### calibrateHigh

    public void calibrateHigh()

  call this method whtn the light sensor is reading the high value - used by reaeValue

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD