Skip to content

Model Train Controlled by Smartphone

Build a model train layout you can control with your smartphone using Arduino, DTMF decoder, and Bluetooth.

  • Arduino
  • Intermediate
  • 90–120 minutes
  • 6 steps

Shop this project

Cart

Prices from vilros.com. Tax and shipping at checkout.

Before you start, you'll need

  • Arduino Uno (or compatible with Adafruit motor shield)
  • Adafruit motor driver shield
  • 12V DC power source
  • DTMF decoder module
  • Bluetooth module
  • Jumper wires
  • 1kΩ-10kΩ resistor
  • Model train track and locomotive

Program the Arduino

About 20 minutes

Set up the Arduino IDE with the Adafruit motor shield library.

  1. Open Arduino IDE and install the Adafruit Motor Shield library (Sketch → Include Library → Manage Libraries, search for 'Adafruit Motor Shield').
  2. Create a new sketch for train control.
  3. The sketch will listen for DTMF tones from your phone and control the motor shield accordingly.

You should see

The Adafruit Motor Shield library is installed and ready.

Modify the DTMF decoder

About 15 minutes

Prepare the DTMF decoder to send signals to Arduino.

  1. Locate the DV LED on the DTMF decoder board (lights up when a tone is detected).
  2. Trace the path from the LED to the chip.
  3. Solder a wire to the copper trace connecting the pin to the resistor that connects to the LED.
  4. This wire will connect to Arduino's analog input.

You should see

A wire is soldered to the DTMF decoder's DV signal path.

Wire all components

About 30 minutes

Connect the motor shield, DTMF decoder, and Bluetooth module.

  1. Connect a pull-down resistor between Arduino GND and A0 pins.
  2. Plug the Adafruit motor shield onto the Arduino by aligning pins and securing firmly.
  3. Connect the track power feeder wires to the M1 screw terminal block on the motor shield.
  4. Connect turnout motors to M3 and M4 screw terminal blocks.
  5. Wire DTMF decoder outputs to Arduino analog inputs: D0→A1, D1→A2, D2→A3, D3→A4, DV→A0.
  6. Connect the Bluetooth module's RX/TX to Arduino's serial pins.

You should see

All components are wired and the motor shield is securely mounted.

Build your track layout

About 30 minutes

Set up a simple test track with turnouts.

  1. Start with a simple loop layout with 1-2 yard sidings for testing.
  2. Place the train locomotive on the track.
  3. Connect power feeders to ensure even power distribution.
  4. Test connections with a multimeter if available.

You should see

The track is assembled and ready for testing.

Connect via Bluetooth

About 10 minutes

Pair your smartphone with the Bluetooth module.

  1. Install a DTMF tone generator app on your smartphone.
  2. Turn on Bluetooth on your phone.
  3. Go to Settings → Bluetooth and find your Bluetooth module's name.
  4. Pair with the module (default PIN is usually 1234 or 0000).

You should see

Your phone is paired with the Bluetooth module.

Test train controls

About 15 minutes

Verify the smartphone can control the train.

  1. Open the DTMF tone generator app.
  2. Default controls: 2=forward, 8=backward, 5=stop, 1&3=first turnout, 4&6=second turnout.
  3. Press '2' to move the train forward.
  4. Press '5' to stop.
  5. Press '8' to reverse.
  6. Test turnout controls by pressing 1, 3, 4, and 6.

You should see

The train responds to DTMF tones from your smartphone.

It didn't work
  • Train doesn't move.

    Check power supply to the track (M1 terminals). Verify motor shield is properly seated on Arduino. Test with a multimeter.

  • DTMF tones don't register.

    Verify DTMF decoder wiring (D0-D3 and DV). Check that the Bluetooth audio is routing to the decoder. Test with a louder phone volume.

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.