Infrared

_images/Infrared.png
class devices.Infrared(ev3handle, layer=1, portnum=1, inputmode='proximity')[source]

The class to represent the EV3 infrared sensor.

Set up an infrared sensor on port number 4

>>> from pyev3.brick import LegoEV3
>>> from pyev3.devices import Infrared
>>> myev3 = LegoEV3(commtype='usb')
>>> mysensor = Infrared(myev3, portnum=4, inputmode='remote')
Parameters
  • ev3handle (object) – LegoEV3 instance representing the EV3 brick.

  • layer (int) – The layer of the brick 1 or 2 in a daisy-chain configuration.

  • portnum (int) – The brick input port connected to the sensor. Possible values are 1, 2, 3, or 4.

  • inputmode (str) –

    • 'proximity' detect proximity to an object

    • 'seeker' searches beacon (requires channel 1 and beacon on)

    • 'remote' takes remote control input

display_info()

Displays a summary with the sensor information.

property inputmode

Contains the sensor input mode. Use this to change the mode on the fly (read/write).

property output

Contains the sensor output based on the inputmode (read only).

  • 0 to 100 (inputmode=’proximity’)

  • tuple of integers (azymuth, proximity) (inputmode=’seeker’)

  • tuple of integers (channel, buttoncode) (inputmode=’remote’)

    • channel 1, 2, 3, 4

    • buttoncode

      • 0 = No button

      • 1 = Button 1

      • 2 = Button 2

      • 3 = Button 3

      • 4 = Button 4

      • 5 = Buttons 1 and 3

      • 6 = Buttons 1 and 4

      • 7 = Buttons 2 and 3

      • 8 = Buttons 2 and 4

      • 9 = Beacon Mode is on

      • 10 = Buttons 1 and 2

      • 11 = Buttons 3 and 4