7

I want to create a block for one light sensor or one motor separately. Is it possible to give the number of the port as a parameter to a sensor or motor block via data wire? In NXT-G it was possible.

1 Answer 1

8

Yes, it is possible to pass the port number as a parameter to a sensor or motor block via data wire. It's just that it's manually selected by default. To change this, go to the port of the sensor or motor block, and select the top-most option which has the plug icon on it:

port option

It will then create a data port for which motor port you want to use:

port data port

The same principle applies with sensor blocks. The input for both sensor and motor blocks is read as number, and you can validly enter a number 1-4 to represent which port.

port data port example

In the above example, a variable is created, and that variable is then passed to both the motor and sensor blocks. Since it was set as 1, it will move motor connected to port A, and wait until the touch sensor connected to port 1 has been touched.

2
  • 1
    I just test with my EV3 with version 1.2.2 and V1.09H firmware I have connected motors to Port A B C, and number 1 to controlling motor at port A, not 0 so the result is 1-4 mapped to port A B C D Hope this helps.
    – dogwong
    Mar 15, 2017 at 17:28
  • 1
    Thank you so much for the correction @dogwong! I have edited my answer to correct this. Mar 19, 2017 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.