Infrared Sensor Block

The Infrared Sensor block gets data from the Infrared Sensor. You can measure sensor data in the Proximity, Beacon, and Remote modes and get Numeric output. You can also compare sensor data to an input value and get a Logic (True or False) output.

See Using the Infrared Sensor for more information about the data provided by the Infrared Sensor, and programming examples.
Tips and Tricks
Tip: The Infrared Sensor block outputs data with Data Wires. See Using the Infrared Sensor for other ways to use the Infrared Sensor that don’t require a data wire.
Choose the Sensor Port and Mode


Port Selector
Mode Selector
Inputs
Outputs

Use the Port Selector on the top of the block to make sure that the sensor port number (1, 2, 3, or 4) matches the port on the EV3 Brick that the Infrared Sensor is connected to.

Use the Mode Selector to select the mode for the block. The Inputs and Outputs available will change depending on the mode.
Modes
Measure - Proximity


The Measure – Proximity mode uses the Infrared Sensor in Proximity mode. The proximity is output in Proximity.
Measure - Beacon


The Measure – Beacon mode uses the Infrared Sensor in Beacon mode. Set the Channel to the beacon channel that you want to detect. The beacon proximity is output in Proximity, and the beacon heading is output in Heading.

The Detected output is True if the beacon is detected. If the beacon is not detected, Detected will be False, Proximity will be 100, and Heading will be 0.
Measure - Remote


The Measure – Remote mode uses the Infrared Sensor in Remote mode. Set Channel to the channel used by the IR Beacon. The Button ID of the currently pressed button, or combination of buttons, is output in Button ID.
Compare Modes


The Compare – Proximity, Compare – Beacon Heading, and Compare – Beacon Proximity modes compare the sensor data to the Threshold Value using the selected Compare Type. The True/False result is output in Compare Result, and the sensor data is output in the chosen sensor data type.
Compare - Remote


The Compare – Remote mode uses the Infrared Sensor in Remote mode. You can select one or more Button ID values in the Set of Remote Button IDs. The Compare Result output will be True if any of the selected buttons is currently pressed on the IR Beacon. The Button ID output will be the Button ID of the currently pressed button or button combination.
Inputs and Outputs
The inputs available for the Infrared Sensor Block will depend on the mode selected. You can enter the input values directly into the block. Alternatively, the input values can be supplied by Data Wires from the outputs of other Programming Blocks.
InputTypeAllowed ValuesNotes
Channel Numeric1 - 4The channel on the IR Beacon to detect.
Compare Type Numeric0 - 50: = (Equal to)
1: ≠ (Not Equal to)
2: > (Greater than)
3: ≥ (Greater than or Equal to)
4: < (Less than)
5: ≤ (Less than or Equal to)
Threshold Value NumericAny numberValue to compare sensor data to
Set of Remote Button IDs Numeric ArrayEach element:
0 - 11
Button ID(s) to test.
See Using the Infrared Sensor Remote Mode.
The outputs available will depend on the mode selected. To use an output, use a Data Wire to connect it to another Programming Block
OutputTypeValuesNotes
Proximity Numeric0 to 100The beacon or object proximity. 0 means very close, and 100 means far away. The Proximity will be 100 if the beacon or object is not detected at all.
Detected LogicTrue/FalseTrue if the beacon is detected.
Heading Numeric-25 to 25The beacon heading. 0 means the beacon is directly in front of the sensor, negative values are to the left, and positive values are to the right.
Button ID Numeric0 - 11Identifies which button, or combination of buttons, is pressed on the IR Beacon.
See Using the Infrared Sensor Remote Mode.
Compare Result LogicTrue/FalseTrue/False result of a Compare mode.
Infrared
Quick links