Touch
-
class
devices.Touch(ev3handle, layer=1, portnum=1, inputmode='touch')[source] The class to represent the EV3 touch sensor.
Set up a touch sensor on port number 1
>>> from pyev3.brick import LegoEV3 >>> from pyev3.devices import Touch >>> myev3 = LegoEV3(commtype='usb') >>> mysensor = Touch(myev3, portnum=1, inputmode='bump')
- Parameters
ev3handle (object) –
LegoEV3instance representing the EV3 brick.layer (int) – The layer of the brick
1or2in a daisy-chain configuration.portnum (int) – The brick input port connected to the sensor. Possible values are
1,2,3, or4.inputmode (str) –
'touch'to check the button state (pressed or released)'bump'to count the number of press/release events
-
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).
1or0(inputmode=’touch’)int(inputmode=’bump’)