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.
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:
It will then create a data port for which motor port you want to use:
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.
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.
1I 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.– dogwongMar 15, 2017 at 17:28
1Thank you so much for the correction @dogwong! I have edited my answer to correct this. Mar 19, 2017 at 21:49