Reference > Brix for Arduino
2.01.006 - Train Controller
Brick 2.01.006 is a WiFi enabled controller for LEGO® PF trains. The controller supports bidirectional communication by means of MQTT messages.
The following MQTT commands can be used to pilot the train controller with a DIY software application.
Note that, before you can communicate with the controller, you have to configure it: WiFi network, password, MQTT broker, etc. This has to be done with our nControl software, this page explains how to do that. Once the controller is configured, you can communicate with it using MQTT messages. When the controller is powered up, it will immeditaly try to connect to the specified WiFi network and MQTT broker; it will keep on trying until it's connected. To send data to the controller, publish messages using the topic nControl/Alias for you messages, where Alias is the name for the controller you specified during configuration in nControl. To receive messages from the controller subscribe to the topic nControl/Alias. The information on this page is intended for personal, non-commercial, use only. Commercial use without prior written approval by 4DBrix LLC is prohibited.
batReturns the battery power as a value between 0 and 1023; 0 specifies 0V and 1023 specifies 9.9V.
Tip: This is a handy command to check whether you're in connection with your controller.
mot,f,powerMakes the motor spin in the forward direction with the specified power; power ranges from 0 (no power) to 1023 (full power).
mot,b,powerMakes the motor spin in the backward/reverse direction with the specified power; power ranges from 0 (no power) to 1023 (full power).
mot,s,power,durationStops the train. The controller supports both hard and soft stops.
Auxiliary Device Port Configuration
prt,2,serwri,baudDefine the third pin of the auxiliary device port as a serial write (TX) line with the specified baud rate. The controller supports the following baud rates: 300, 1200, 2400, 4800, 9600 ,19200, 38400, 57600, 74880, 230400 and 250000.
prt,2,digoutDefine the third pin of the auxiliary device port as a digital out port.
The following command will only be executed if the port has been configured as a serial write (TX) port.
cmd,2,dataSend the specified data as a serial message over the third pin of the auxiliary device connector.
The following commands will only be executed if the port has been configured as a digital out port.
set,2,highSets the third pin of the auxiliary device port to HIGH; =3.3V.
set,2,lowSets the third pin of the auxiliary device port to LOW; =0V.
set,2,valueSets the third pin of the auxiliary device port to a specific voltage using PWM; value rages from 0 to 1023.