2-phase driver for Stepper Motors


The 2-Phase stepper motor driver is used to control bipolar stepper motors in conjunction with an H-bridge by driving it outputs to perform rotations. The signals from the Builder Base are what the motor requires but the H-Bridge is needed to provide enough current to the coils in the stepper motor. To drive the stepper motor we need the full H-Bridge which is different than with the DC motor, where we only used half of it.

Driver Parameters

The 2-Phase Stepper Motor driver has six parameters that need to be configured:


This is the first pin driving the A coil of the motor.


This is the second pin driving the A coil of the motor.


This is the first pin driving the B coil of the motor.


This is the second pin driving the B coil of the motor.


This is the revolutions the motor performs per minute. We can handle revolutions per minute between 5 and 60 with the default being 10.


The steps per revolutions tells the driver how often the coils have to be energized to determine a full rotation. This value can be found very prominently in the datasheet of the motor.


Two widely used H-Bridge ICs are the L293D from multiple suppliers and the SN754410 from Texas Instruments. Their pinout can be seen below:

Some important facts about the chip:

  • all 0V (GND) pins should be connected, since they also dissipate the heat from the chip

  • pin 16 (+V) should be at 5V to provide proper functionality while pin 8 (+Vmotor) can be anything between 3.5V and 12V


We just use the L293D H-bridge as an example!

The L293d has a maximum power rating which can be found in its datasheet. In general the stepper should not draw more than 0.8A roughly at 12V, otherwise the IC can overheat and unexpected behavior occurs. There are different solutions like more beefier H-Bridges or just using plain transistors/MOSFETs to drive the Motor. Actually the step direction driver offers a more compact solution with a higher current rating, check it out: https://quantumintegrate.atlassian.net/wiki/spaces/QFR/pages/148308581


In this example, the 2-Phase Stepper motor is connected to an L293D H-Bridge. From the Builder Base, the 5V pin is connected to the 3,4 Enable, VCC1, and 1,2 Enable pins on the chip; the GND pins are connected to the GND1, GND2, GND 3, and GND 4 pins on the chip, and to the GND pin on our power supply. GPO is connected to Input 1, GP1 to input 2, GP2 to Input 3, and GP3 to Input 4. From the chip, output 1 is connected to A, output 2 is connected to C, output 3 is connected to B, and output 4 is connected to D. Lastly, the positive voltage from our power supply is connected to VCC2 on the chip. We use an external power supply for the motor voltage here because most stepper motors run on 12V.

Note: In the schematic the poles for each coil are labeled A, B, C and D instead of A+, A-, B+ and B- like in our driver. This is purely a difference in naming convention that occurs between stepper motors manufactured by different companies and different schematics. All that matters is that The H-Bridge outputs driven by A+ and A- are connected to one coil and the ones driven by B+ and B- are connected to the other coil.



Used Pins

Used Pins


Used Pins


GP0: (Can be any GP pin)

Used to control pole A; Connected to Input 1

GP1: (Can be any GP pin)

Used to control pole C; Connected to Input 2

GP2: (Can be any GP pin)

Used to control pole B; Connected to Input 3

GP3: (Can be any GP pin)

Used to control pole D; Connected to Input 4

+ voltage (from power supply)

Provides power to stepper (+Vmotor on H-Bridge)


Provides 5V power for the H-bridge; Connected to 3,4Enable, 1,2 Enable, and VCC1


Provides grounding for the circuit: Connected to GND 1,2,3,4, and GND pin on power supply

How to write an App

Navigate to the App Builder and create a new application. You can find the “Stepper Motor” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.




Drag the “Stepper Motor” Object onto the canvas.

Next, locate the “Button” and “Input Number” Objects under the interface tab and drag two instances of the “Button” Object and one instance of the “Input Number” Object onto the canvas.



Finally, from the “Button” Objects connect one state port to the Increment port and one state port to the Decrement port on the “Stepper Motor” Object. From the “Input Number” Object connect the Number port to the Steps in Degrees port. If you wish, label your code objects for easier identification on the dashboard, and save your application.


How to create a firmware

Navigate to the Firmware Builder and create a new firmware file.

Click the “+ Add Hardware” button which will open a modal window. Scroll down in the list to find the “Generic” section and select the “Stepper Motor” hardware option.

Give your device a name, and click “Add Device”




Next, select the “2-Phase ” driver under the driver dropdown menu.




For this example we select:

  • A+ Pin: GP0

  • A- Pin: GP1

  • B+ Pin: GP2

  • B- Pin: GP3

  • RPM: 10

  • Steps/Rev: 200

You may now save your firmware file and upload it to one of your clients.




Supported Hardware

  • Stepper Motor