Port names¶
Classes such as ev3dev2.motor.Motor and those based on
ev3dev2.sensor.Sensor accept parameters to specify which port the
target device is connected to. This parameter is typically caled address.
The following constants are available on all platforms:
Output
ev3dev2.motor.OUTPUT_Aev3dev2.motor.OUTPUT_Bev3dev2.motor.OUTPUT_Cev3dev2.motor.OUTPUT_D
Input
ev3dev2.sensor.INPUT_1ev3dev2.sensor.INPUT_2ev3dev2.sensor.INPUT_3ev3dev2.sensor.INPUT_4
Additionally, on BrickPi3, the ports of up to four stacked BrickPi’s can be referenced as OUTPUT_E through OUTPUT_P and INPUT_5 through INPUT_16.
Example
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B
from ev3dev2.sensor import INPUT_1
from ev3dev2.sensor.lego import TouchSensor
m = LargeMotor(OUTPUT_A)
s = TouchSensor(INPUT_1)