Special sensor classes

The classes derive from Sensor and provide helper functions specific to the corresponding sensor type. Each of the functions makes sure the sensor is in the required mode and then returns the specified value.

Touch Sensor

class Touch_Sensor

Touch Sensor

inherits from: sensor

Target driver(s): lego-ev3-touch, lego-nxt-touch

Special properties

Is_Pressed

boolean, read

A boolean indicating whether the current touch sensor is being pressed.

Required mode: TOUCH

Value index: 0

Color Sensor

class Color_Sensor

LEGO EV3 color sensor.

inherits from: sensor

Target driver(s): lego-ev3-color

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-ev3-color-sensor/

Special properties

Reflected_Light_Intensity

int, read

Reflected light intensity as a percentage. Light on sensor is red.

Required mode: COL-REFLECT

Value index: 0

Ambient_Light_Intensity

int, read

Ambient light intensity. Light on sensor is dimly lit blue.

Required mode: COL-AMBIENT

Value index: 0

Color

int, read

Color detected by the sensor, categorized by overall value.
  • 0: No color
  • 1: Black
  • 2: Blue
  • 3: Green
  • 4: Yellow
  • 5: Red
  • 6: White
  • 7: Brown

Required mode: COL-COLOR

Value index: 0

Red

int, read

Red component of the detected color, in the range 0-1020.

Required mode: RGB-RAW

Value index: 0

Green

int, read

Green component of the detected color, in the range 0-1020.

Required mode: RGB-RAW

Value index: 1

Blue

int, read

Blue component of the detected color, in the range 0-1020.

Required mode: RGB-RAW

Value index: 2

Ultrasonic Sensor

class Ultrasonic_Sensor

LEGO EV3 ultrasonic sensor.

inherits from: sensor

Target driver(s): lego-ev3-us, lego-nxt-us

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-ev3-ultrasonic-sensor/

Special properties

Distance_Centimeters

float, read

Measurement of the distance detected by the sensor, in centimeters.

Required mode: US-DIST-CM

Value index: 0

Distance_Inches

float, read

Measurement of the distance detected by the sensor, in inches.

Required mode: US-DIST-IN

Value index: 0

Other_Sensor_Present

boolean, read

Value indicating whether another ultrasonic sensor could be heard nearby.

Required mode: US-LISTEN

Value index: 0

Gyro Sensor

class Gyro_Sensor

LEGO EV3 gyro sensor.

inherits from: sensor

Target driver(s): lego-ev3-gyro

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-ev3-gyro-sensor/

Special properties

Angle

int, read

The number of degrees that the sensor has been rotated since it was put into this mode.

Required mode: GYRO-ANG

Value index: 0

Rate

int, read

The rate at which the sensor is rotating, in degrees/second.

Required mode: GYRO-RATE

Value index: 0

Infrared Sensor

class Infrared_Sensor

LEGO EV3 infrared sensor.

inherits from: sensor

Target driver(s): lego-ev3-ir

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-ev3-infrared-sensor/

Special properties

Proximity

int, read

A measurement of the distance between the sensor and the remote, as a percentage. 100% is approximately 70cm/27in.

Required mode: IR-PROX

Value index: 0

Sound Sensor

class Sound_Sensor

LEGO NXT Sound Sensor

inherits from: sensor

Target driver(s): lego-nxt-sound

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-nxt-sound-sensor/

Special properties

Sound_Pressure

float, read

A measurement of the measured sound pressure level, as a percent. Uses a flat weighting.

Required mode: DB

Value index: 0

Sound_Pressure_Low

float, read

A measurement of the measured sound pressure level, as a percent. Uses A-weighting, which focuses on levels up to 55 dB.

Required mode: DBA

Value index: 0

Light Sensor

class Light_Sensor

LEGO NXT Light Sensor

inherits from: sensor

Target driver(s): lego-nxt-light

ev3dev docs link: http://www.ev3dev.org/docs/sensors/lego-nxt-light-sensor/

Special properties

Reflected_Light_Intensity

float, read

A measurement of the reflected light intensity, as a percentage.

Required mode: REFLECT

Value index: 0

Ambient_Light_Intensity

float, read

A measurement of the ambient light intensity, as a percentage.

Required mode: AMBIENT

Value index: 0