To operate LEGO train with Power Functions motors, you need the MattzoTrainController for Power Functions.
Watch this video to learn about the MattzoTrainController for Power Functions:
The “MattzoTrainController for Power Functions” consists of a micro controller and a motor shield. The controller receives messages from RocRail via MQTT, parses the commands and powers the motors, which are directly attached to the controller with standard Power Function cables.
One or two powered function motors can be connected to the controller. If two motors are attached, they can be configured to run in concurrent or reverse direction. Additionally, the controller has two ports for LEDs or other consumers, which can be used to switch train headlights or other accessories on and off.
The controller is ready, operational and tested.
Building instructions can be found here.
Have fun while building it!