-
Notifications
You must be signed in to change notification settings - Fork 0
LEGO EV3 Infrared Sensor (45509)
This sensor uses the msensor device class.
Value | |
---|---|
type_id |
33 |
# Modes | 6 |
Connection | UART |
Mode 0 | Mode 1 | Mode 2 | Mode 3 | Mode 44 | Mode 55 | |
---|---|---|---|---|---|---|
mode
|
IR-PROX
|
IR-SEEK
|
IR-REMOTE
|
IR-REM-A
|
IR-S-ALT
|
IR-CAL
|
Description | Proximity | IR Seeker1 | IR Remote Control2 | Alternate IR Remote Control | Alternate IR Seeker | Calibration??? |
num_values
|
1
|
8
|
4
|
1
|
4
|
2
|
value0
|
Proximity (distance) | Channel 1 Heading | Channel 1 | Channel 13 | ??? | |
Min |
0 (very close)
|
-25 (far left)
|
0 (none)
|
0 (???) | 0 (???) | |
Max |
100 (far away - approx. 70cm/27in)
|
25 (far right)
|
11 (blue up and blue down)
|
100 (???) | 1023 (???) | |
value1
|
Channel 1 Proximity | Channel 2 | ??? | |||
Min |
0 (close)
|
0 (none)
|
0 (???) | 0 (???) | ||
Max |
100 (far away - approx. 200cm/79in)
|
11 (blue up and blue down)
|
100 (???) | 1023 (???) | ||
value2
|
Channel 2 Heading | Channel 3 | ??? | |||
Min |
-25
|
0 (none)
|
0 (???) | |||
Max |
25
|
11 (blue up and blue down)
|
100 (???) | |||
value3
|
Channel 2 Proximity | Channel 4 | ??? | |||
Min |
0
|
0 (none)
|
0 (???) | |||
Max |
100
|
11 (blue up and blue down)
|
100 (???) | |||
value4
|
Channel 3 Heading | |||||
Min |
-25
|
|||||
Max |
25
|
|||||
value5
|
Channel 3 Proximity | |||||
Min |
0
|
|||||
Max |
100
|
|||||
value6
|
Channel 4 Heading | |||||
Min |
-25
|
|||||
Max |
25
|
|||||
value7
|
Channel 4 Proximity | |||||
Min |
0
|
|||||
Max |
100
|
|||||
units
|
pct (percentage)
|
pct (percentage)
|
btn (button2)
|
none3 |
pct (percentage)
|
none |
dp (decimal places)
|
0
|
0
|
0
|
0
|
0
|
0
|
[1]: The absence of a beacon on a channel can be detected when Proximity == -128 (and heading == 0).
[2]: Pressing more that 2 buttons at one time is not supported. It will usually read 0. Pressing an up/down button while beacon mode is activated with turn off beacon mode.
Value | Description |
---|---|
0 | none |
1 | red up |
2 | red down |
3 | blue up |
4 | blue down |
5 | red up and blue up |
6 | red up and blue down |
7 | red down and blue up |
8 | red down and blue down |
9 | beacon mode on |
10 | red up and red down |
11 | blue up and blue down |
[3]: The most significant byte is always 0x01. In the least significant byte, the 4 most significant bits represent each button. Bit 7 is the blue down button, bit 6 is the blue up button, bit 5 is the red down button, bit 4 is the red up button. Beware that when no buttons are pressed, bit 7 is set (value == 384). You can test that bits 0-3 are all 0 to check this.
if ((value & 0x0F) == 0) {
// no buttons are pressed
} else {
if (value & 0x80)
// blue down button is pressed
if (value & 0x40)
// blue up button is pressed
if (value & 0x20)
// red down button is pressed
if (value & 0x10)
// red up button is pressed
}
Bits 0-3 seem to be some sort of checksum or parity check. Bit 0 = bit 4, bit 1 = ~(bit 5), bit 2 = ~(bit 6), bit 3 = 0 if bits 0-2 are even or 1 if bits 0-2 are odd.
Also, when the beacon mode is active or for about 1 second after any button is released the value is 262. This mode only works with the remote on channel 1.
Value | Blue Down | Blue Up | Red Down | Red Up |
---|---|---|---|---|
262/384 | ||||
287 | X | |||
300 | X | |||
309 | X | X | ||
330 | X | |||
339 | X | X | ||
352 | X | X | ||
377 | X | X | X | |
390 | X | |||
415 | X | X | ||
428 | X | X | ||
437 | X | X | X | |
458 | X | X | ||
467 | X | X | X | |
480 | X | X | X | |
505 | X | X | X | X |
X = Button pressed |
[4] IR-S-ALT mode does not seem to be usable. When switching to this mode, the sensor quits responding to the keep-alive messages and the sensor resets.
[5] Not sure how this IR-CAL mode is supposed to work. Probably have to write some data to the sensor. Values return 0.