Assembly & Setup

Propeller Beanie


For assembly, we will assume the default ULN2003/28BYJ-48 combo is in use with an Arduino Nano V3, a standard 3 pin Arduino compatible hall effect sensor, and a dual relay board.

We will also assume a prototyping shield is available that provides regulated 5V power sufficient for driving the ULN2003/28BYJ-48 stepper combo, and that there is a power supply with a suitable DC power plug to suit the prototyping shield.

Throughout the assembly process, you can refer to this Fritzing diagram to help validate your connections are correct (open this image in a new tab or window and zoom in to see the detail):

Fritzing Diagram

Connection summary

Summary table of all connections required during assembly:

Device Pin

Arduino Pin

Nano Shield Pin

ULN2003 IN1


A0 S

ULN2003 IN2


A1 S

ULN2003 IN3


A2 S

ULN2003 IN4


A3 S

ULN2003 +


A0 V

ULN2003 -


A0 G

Hall effect - (Left)


5 G

Hall effect Unmarked (middle)


5 V

Hall effect S (Right)


5 S

Dual relay VCC


3 V

Dual relay GND


3 G

Dual relay IN1


3 S

Dual relay IN2


4 S

CommandStation 20 (SDA)


A4 S or SDA

CommandStation 21 (SCL)


A5 S or SCL

CommandStation GND


A4 G or I2C GND

Of course for the Tinkerers and Engineers, if you’re not using a Nano or a prototyping shield, adapt the details as suits your configuration.

1. BEFORE you start

Gather all your components and visually check them all for any obvious damage, paying particular attention to pins on the Arduino to make sure they are straight.

Components Nano Pins

2. Insert the Nano into the shield

Insert the Nano into the prototype shield socket, taking care to ensure the USB socket is located at the same end as the DC power jack, and that all pins are straight and aligned correctly with the female headers.

The various pin numbers may also be printed on the prototyping shield to confirm the correct orientation.

Insert Nano Nano Inserted

At this point, it’s a good idea to take careful note of the various pin markings on your prototype shield as it’s critical that these are correct when connecting the various components.

With the shield used in these assembly photos, you will note that each of the Nano GPIO pins has three pins associated with it marked “G” for ground, “V” for 5V, and “S” for signal, with this last pin being the actual Nano GPIO pin.

Prototype Shield Pins

3. Connect the stepper controller and motor

Firstly, note that the ULN2003 controller will have four pins marked “IN1” through “IN4”, as well as a pair of pins with “+” and “-”. There is a likely a jumper installed across two pins beside these that is unmarked, leave this in place.

You will need to connect six of the female to female Dupont wires from the ULN2003 pins to the Arduino prototype shield as below:

ULN2003 Pin

Nano Shield Pin


A0 S


A1 S


A2 S


A3 S


A0 V


A0 G

ULN2003 Pins Shield to ULN2003 pins

Insert the stepper motor connector into the recepticle on the ULN2003 controller. Note that it will only go in one way, so check the orientation and simply plug it in.

28BYJ-48 Connector 28BYJ-48 Connector

4. Connect the hall effect sensor

The hall effect sensor has three pins, and likely only two of these pins are marked, the left with “-” and right with “S”. The middle pin is likely to be unmarked, and will be the 5V pin. There are probably many different varieties of sensors and designs out there, but both that I have (from different suppliers) are marked identically.

Use three of the Dupont wires and connect these from the hall effect sensor to the Arduino prototype shield as below:

Hall Effect Pin

Nano Shield Pin

- (Left)

5 G

Unmarked (middle)

5 V

S (Right)

5 S

Hall Effect Pins Hall Effect to Shield

5. Connect the dual relay board

Note there should be six pins on the dual relay board marked “VCC”, “GND”, “IN1”, “IN2”, “COM”, and “GND”. The “COM” and “GND” pins should have a jumper installed to connect these together. Leave this in place.

Use four Dupont wires to connect the other four pins as below:

Dual Relay Pin

Nano Shield Pin


3 V


3 G


3 S


4 S

Dual Relay Pins Dual Relay to Shield Pins

6. Connect power and test

At this point, it should be safe to plug in the power supply to the DC power jack on the prototyping shield.

When the power supply is turned on, the power LEDs on the Arduino Nano and dual relay board should be lit. Note there is likely no power LED on the ULN2003 stepper controller, and testing of this will require loading the EX‑Turntable software on to the Nano in step 7 below.

Powered On

To validate the hall effect sensor is connected correctly, put a magnet in close proximity (within a millimetre or so) of the sensor IC, and the onboard LED should light up.

Hall Effect Inactive Hall Effect Active

7. Load the EX-Turntable software


Please read through this entire section prior to loading any software onto your Arduino. It is also recommended that the turntable is able to trigger the homing sensor correctly to ensure the automatic calibration works correctly at first startup.

Further to this, note that you will need to end up with two separate folders; one containing the EX‑CommandStation software as per Install using the Arduino IDE, and an additional folder containing the EX‑Turntable software. The EX‑Turntable software is not a component of EX‑CommandStation or vice versa, and as such they should not exist in the same folder.

At the time of writing, there is no installer for EX‑Turntable like there is for the CommandStation, so you will need to install the Arduino IDE and load the software onto the Arduino manually.

As noted in the tip above, you should have a EX‑Turntable folder alongside the EX‑Turntable folder, and neither should reside in the other (the EX‑Turntable software is required in the next step):

Two folders

The process here is the same as installing CommandStation-EX via the Arduino IDE which you can find on the Install using the Arduino IDE page.

When you get to the point of opening the sketch, ensure you open the EX-Turntable sketch:

Open EX-Turntable sketch

Use Windows Explorer to either copy or rename “config.example.h” to “config.h”.

If you need to make adjustments to config.h, refer to the Configuration options.

Set the board type to “Nano” and set the correct Processor type (typically ATMega328P):

Select Nano

After any adjustments are made and “config.h” has been created, the software can be uploaded to the Arduino with the upload button:


Once the software is loaded successfully on to EX‑Turntable, the stepper motor should automatically start rotating in an attempt to find its “home” position, which will be activated when the magnet at one end of the turntable comes in close proximity to the hall effect sensor.

If you don’t have the magnet installed at this point, or if it is too far from the sensor, EX‑Turntable will rotate several turns prior to flagging that homing has failed, and will then cease turning. The automatic calibration process will not commence if homing has failed.

If your testing of the hall effect sensor in step 6 above succeeded, then the issue is likely to be the distance the magnet is from the sensor, and this will require adjustment. See EX-Turntable FAQ and Troubleshooting for further assistance if required.

First start and automatic calibration


If you have loaded the code too soon, and the automatic calibration has succeeded and recorded an inaccurate step count, then have no fear as there is a command you can run on the CommandStation to reinitiate the calibration sequence which is outlined in the Ex-Turntable commands section.

As of v0.5.0-Beta, you can also execute the command <0 3> in the serial console to initiate the calibration sequence.

Also, if you have enabled the FULL_STEP_COUNT option in “config.h”, that will prevent automatic calibration occurring, refer to FULL_STEP_COUNT.

When EX‑Turntable is first loaded onto your Arduino, and it has successfully performed the homing process outlined above, it will commence an automatic calibration sequence. This involves several rotations of the turntable to ensure it is homed accurately, and is then able to count the steps required to complete a full rotation of the turntable.

Once the calibration sequence has completed, it will display the step count for an entire rotation, which you should take note of for calculating the various positions in Tuning your turntable positions.

On the first start, the output in the serial console should look similar to the below:

License GPLv3 fsf.org (c) dcc-ex.com
EX-Turntable version 0.5.0-Beta
Available at I2C address 0x60
EX-Turntable in TURNTABLE mode
EX-Turntable has not been calibrated yet
Automatic phase switching enabled at 45 degrees
Phase will switch at 0 steps from home, and revert at 0 steps from home
Homing started
Turntable homed successfully
CALIBRATION: Phase 1, homing...
CALIBRATION: Phase 2, counting full turn steps...
CALIBRATION: Completed, storing full turn step count: 4100                    <<== This is the full turn step count to record for later reference
EX-Turntable has been calibrated for 4100 steps per revolution
Automatic phase switching enabled at 45 degrees
Phase will switch at 495 steps from home, and revert at 2475 steps from home
Turntable homed successfully

At this point, the full turn step count is written to the Arduino’s EEPROM so that it can be retrieved each time EX‑Turntable starts up, preventing the need to repeat the calibration sequence at each subsequent start.

You can now safely power off EX‑Turntable and remove the USB cable from your PC as it is no longer required for normal operation, and all further commands will be issued by the CommandStation.

8. Add the EX-Turntable device driver to EX-CommandStation


As mentioned previously, your CommandStation needs to be running the “add-turntable-controller” branch of EX-CommandStation.

This will display in the serial console of your CommandStation as version 4.0.2.

If the “myHal.cpp_example.txt” is missing the lines referred to below, or if you receive compile errors that the file “IO_EXTurntable” is missing when attempting to upload the CommandStation software later in this process, this indicates you are using the incorrect version of EX‑CommandStation.

The zip file containing the correct version of EX‑CommandStation should also be attached to the EX‑Turntable release.

Before you will be able to test or use EX‑Turntable, you need to configure the EX‑CommandStation software to load the appropriate device driver.

This requires creating or editing the myHal.cpp file in the EX‑CommandStation code and uploading it to your CommandStation.


It is helpful to have a high level understanding of how device drivers and the HAL works in the CommandStation as explained on the I/O Device Drivers and HAL page. However, if that page is more information than you require at this point, then follow the steps below to add the required EX‑Turntable device driver and device.

Before continuing, refer to the file “myHal.cpp_example.txt” included with the EX‑CommandStation software, and note the following.

At the top of the file there are a number of lines beginning with “#include”:

// Include devices you need.
#include "IODevice.h"
#include "IO_HCSR04.h"    // Ultrasonic range sensor
#include "IO_VL53L0X.h"   // Laser time-of-flight sensor
#include "IO_DFPlayer.h"  // MP3 sound player
//#include "IO_EXTurntable.h"   // EX-Turntable turntable controller

Note the last line, this is the device driver required to enable EX‑Turntable support.

Scrolling down towards the bottom of that file, you will also see this indented section:

// The following directive defines an EX-Turntable turntable instance.
// EXTurntable::create(VPIN, Number of VPINs, I2C Address)
// The parameters are:
//   VPIN=600
//   Number of VPINs=1 (Note there is no reason to change this)
//   I2C address=0x60
// Note that the i2c address is defined in the EX-Turntable code, and 0x60 is the default.

//EXTurntable::create(600, 1, 0x60);

If you don’t have an existing “myHal.cpp” file, then follow these steps to create a new one: Adding a New Device. Note that you don’t need to worry about copying or providing device driver files, as these are already included with the EX‑CommandStation software.

Copy and paste the relevant lines from the “myHal.cpp_example.txt” file as above, which should result in the following content in your new “myHal.cpp” file:

#include "IODevice.h"
#include "IO_EXTurntable.h"   // EX-Turntable turntable controller

void halSetup() {
  // The following directive defines a EX-Turntable turntable instance.
  // EXTurntable::create(VPIN, Number of VPINs, I2C Address)
  // The default parameters are:
  //   VPIN=600
  //   Number of VPINs=1 (Note there is no reason to change this)
  //   I2C address=0x60
  // Note that the i2c address is defined in the EX-Turntable code, and 0x60 is the default.

  EXTurntable::create(600, 1, 0x60);

In the device setup above, there are three parameters provided, but only two may need to change in your environment if you have other devices that may conflict with these two settings:

  • VPIN=600 - This is the default virtual pin (Vpin) ID that is used to send EX‑Turntable commands to. Vpin IDs need to be unique, so if this ID is used elsewhere, change as necessary (refer Overview).

  • I2C address=0x60 - This is the default address on the I2C bus that the EX‑Turntable is configured to use. This address also needs to be unique, so change this also if it is in use elsewhere, both in “myHal.cpp” and in “config.h” in the EX‑Turntable software.

If you already have an existing “myHal.cpp” file, then you simply need to add these entries in the appropriate sections of your existing file, noting that the “#include” needs to be before “void halSetup() {” and the “EXTurntable::create…” needs to be before the final “}”.

Follow the rest of the directions for Adding a New Device all the way through to the Upload the new version of the software step to upload your newly configured CommandStation.

Note there is no point in checking the driver at this stage as EX‑Turntable is not connected, and will show as “OFFLINE”.

9. Connect EX-Turntable to your EX-CommandStation

To control EX‑Turntable from your CommandStation, you will need a connection to the I2C (SDA, SCL) pins.


Ensure you turn the power off to both your CommandStation and EX‑Turntable prior to making any of these connections.

On the CommandStation, assuming this is a Mega2560 or Mega2560 + WiFi, the SDA (pin 20) and SCL (pin 21) pins are typically labelled as such, so should be easy to identify.

On an Arduino Nano (and Uno) however, the SDA and SCL pins are shared with analog pins A4 and A5, and therefore aren’t explicitly labelled. The SDA pin is A4, and the SCL pin is A5.

Connect these pins to your CommandStation as shown in the table below, noting that it is important to ensure the ground is also connected to ensure the I2C communication is reliable.

CommandStation Pin

Nano Shield Pin

20 (SDA)

A4 S (SDA)

21 (SCL)

A5 S (SCL)

Any spare ground

A4 G

Nano I2C pins Nano I2C pins Nano I2C pins

Now you’re ready!

At this point, you should have a fully assembled EX‑Turntable with the software loaded, a default configuration, and the device driver installed and configured in your CommandStation.

In addition, EX‑Turntable should be connected to your CommandStation ready to test, tune your turntable positions, and configure EX-RAIL ready for use on your layout.

Click the “next” button to get cracking!