Documentation > nControl > Getting Started
Controlling Trains
For nControl™ 2018.1 or higher
This article explains how to control LEGO® trains (PF motor) with nControl using a WiFi train controller.
Configuring the train controller
The first step is to configure the train controller for your WiFi network and computer you're running nControl on. A detailed description on how to do that can be found here.
Creating the train control tile
Trains can be piloted with train control tiles. To create one: switch to Configuration Mode by clicking the button in the main toolbar and select the train control tile in the panel on the left-hand side.

This will open the Edit Train Control Properties dialog window:

The two most important settings are Label and Motor Position:
  • Label: The label is not only displayed at the top of the tile, it also determines to which train controller the instructions will be sent. The Label of the tile has to match the Alias of the train controller. Note that tile labels are case sensitive; the label has to be identical to the alias of the train controller otherwise the train controller will not receive the instructions the tile is sending.
  • Motor Position: Here you specify whether the PF motor is in the front or back of the train. The motor position is important to know which direction is forward. Misconfiguration of the motor position will cause the train to go in the wrong direction.
The Label Color, Label Text, and Label Logo can be used to customize the look of the train control tile and make it match the design of the train it's controlling. These settings have however no impact on the behavior of the train, they are purely aesthetic.
Close the dialog box with the OK button to create the train control tile.
Controlling trains from nControl
To control your train, switch to Operational Mode by clicking on the icon.

You can now control the train with your train control tile:
  • Power: you can change the motor power by clicking on the power indicator; the orange arch in the image above. Clicking on the or buttons increases or decreases the power with 10%.
  • Direction: you can choose the direction you want to go in with the arrow buttons. Choose to go forward and to reverse. The current direction is indicated in white, the other direction is grayed.
  • Stop: you can stop by clicking on the button or by settings the power to 0. Setting the power to 0 results in a soft stop; the trains comes to a halt in a gentle way by simply switching off the motor. The button can be used for a hard stop using reverse power: the motor is briefly actuated in the opposite direction to stop faster. The reverse power settings can be customized in the Advanced settings of the Edit Train Control Properties dialog box.
  • Horn: you can play a train horn sound on your computer by clicking the button. The horn sound can be customized in the Advanced settings of the Edit Train Control Properties dialog box.
  • Battery: the train controller has a battery sensor and provides feedback on the battery status. The battery icon indicates the remaining battery power of the train.
Controlling trains with mobile devices
You can control the trains with a phone of tablet as well. To do this, you need to:
  • export your nControl project as a web interface
  • open the interface on your mobile device using a web browser
Detailed instructions on how to do that can be found here.
Keep in mind that your mobile device will not connect to the train directly, it will connect to the computer running nControl. As such it will also be possible to control and monitor other devices in your layout: track switches, traffic lights,... or other trains.
Automating trains
You can automate the train by, for example, making them respond to train detection sensor feedback. You can do this with Python scripts in tiles of the devices to which the train has to respond. The API functions to control the train can be found here.
Troubleshooting
If your train does not respond:
  • Check if the train controller is connected to nControl. To do so choose Controller > MQTT Broker in the main menu and check for a 4DBrix WiFi controller connected message.
  • Check if the Alias of the train controller is identical to the Label of the tile. Remember, the label and alias are case sensitive. Blank spaces are important too: 'Train 1' is not the same as 'Train1'.
If your train goes in the wrong direction:
  • Check the Motor Position setting in the Edit Train Control Properties dialog box.