Sensor Appendix

EV3 Basic does a good job auto-detecting many sensors, at least all sensors that came with the NXT 2.0 and EV3 kit. Nevertheless the program needs to know how to best interpret the sensor readings for the different types and modes. To keep the list simple, I only include the modes which, I feel, make sense to use anyway. The EV3 sensors are listed first and the NXT sensors are listed in a separate table lower down. 
  • Use ReadPercent(port number) to obtain a single value in the range 0-100. 
  • Use ReadRawValue(port number, index) if you need to obtain a single non-percentage value, such as a color code. The index value for ReadRawValue should normally be zero except if you need to obtain value1 or value2 from the sensor, as shown in the table below.
  • Use ReadRaw(port number, number of elements) when you need to obtain multiple values from the sensor (in an array). See the sensor page and the manual

EV3 Sensors

Type  Mode  Name             Get reading with Returns
16 0 TOUCH  ReadPercent 0=not pressed,  100=pressed
29
29
29


29
0
1
2


4
COL-REFLECT
COL-AMBIENT
COL-COLOR


RGB-RAW
ReadPercent
ReadPercent
ReadRawValue


ReadRaw (3 vals)
0=no reflected light, 100=max
0=no ambient light, 100=max
0=unknown, 1=black, 2=blue, 3=green, 4=yellow, 5=red, 6=white, 7=brown
value0=red intensity, value1=green intensity, value2=blue intensity
30
30
0
1
US-DIST-CM
US-DIST-IN
ReadRawValue
ReadRawValue
distance in mm
distance in tenths of an inch
32
32
0
1
GYRO-ANG
GYRO-RATE
ReadRawValue
ReadRawValue
angle in degrees(**)
rate of change of angle in deg/s
33
33

33
0
1

2
IR-PROX
IR-SEEK

IR-REMOTE
ReadRawValue
ReadRaw (2 vals)

ReadRawValue***
distance in cm (not very accurate)
value0=direction to IR beacon
value1=distance to IR beacon
value0=signal from channel 1 (*), value1=signal from channel 2...

The IR beacon (remote control transmitter) can be switched to use one of 4 channels (slider on top position is channel 1) and the IR sensor (remote receiver) can detect all channel signals at the same time.

(*) numbers for the remote control buttons (A=left top, B=left bottom, C=right top, D=right bottom, E=beacon activated):
A = 1        A&B = 10      B&C = 7
B = 2        A&C = 5        B&D = 8
C = 3        A&D = 6        C&D = 11
D = 4
        E = 9
other combinations give a reading of 0

(**) Note that the gyro sensor measures turn angles in degrees but Small Basic trigonometric functions use radians. Know that 1 radian = 57.3° approx.

(***) Assuming you are using a single IR remote control and thus a single channel.

NXT Sensors

Type  Mode  Name             Get reading with Returns
1 0 NXT-TOUCH  ReadPercent 0=not pressed,  100=pressed
4
4
4
0
1
2****
NXT-REFLECT
NXT-AMBIENT
NXT-COLOR
ReadPercent
ReadPercent
ReadRawValue
0=no reflected light, 100=max
0=no ambient light, 100=max
1=black, 2=blue, 3=green, 4=yellow, 5=red, 6=white
5 0 NXT-US-CM ReadRawValue distance in cm

(****) The webmaster says: I am unable to obtain mode 2 (color detect) of the NXT color sensor. Is my sensor broken?
Comments