10 min

Control the movement of two DC motors or one bipolar stepper motor with DRV8834 and STM32F407VGT6

Dual H-bridge current-control motor driver

H-Bridge 15 Click with Clicker 4 for STM32F4

Published Dec 29, 2023

Click board™

H-Bridge 15 Click

Development board

Clicker 4 for STM32F4


NECTO Studio



Compact and adaptable solution for managing motor-driven functions in various applications



Hardware Overview

How does it work?

H-Bridge 15 Click is based on the DRV8834, a dual-bridge stepper or DC motor driver from Texas Instruments. The output driver block of each H-Bridge consists of N-channel power MOSFETs configured as an H-Bridge to drive the motor windings. Each H-Bridge includes circuitry to regulate or limit the winding current. There are two general control modes. The indexer logic with simple step/direction control and up to 1/32-step micro-stepping is one. The other is a phase/enable control that can drive external references for more than 1/32-step micro-stepping. The PCA9538, a low-voltage 8-bit I/O port from NXP, controls the logic states of the motor driver inputs. By setting the CONFIG input pin of the motor driver to a HIGH

state, you can select the indexer mode. Otherwise, you can select the phase/enable mode. Please note that you can drive DC motors only in phase/enable mode, while a stepper motor can be driven in any of these. The PCA9538 allows you to control the enable inputs of both bridges, micro-step modes, step inputs, direction, sleep mode, and more. It even takes the fault outputs of the motor driver. The voltage reference for both bridges is provided by the motor driver voltage reference output and two onboard potentiometers labeled VREF A and VREF B. Over those potentiometers, you can set the winding current for both bridges. The decay modes for both bridges are left for you to set over unpopulated jumper resistors. H-Bridge

15 Click uses a standard 2-wire I2C interface of the PCA9538 to allow the host MCU to control the motor driver inputs. It also notifies the host MCU if any fault condition occurs over the INT pin. The RST pin allows you to reset the PCA9538. The i2c address for this I/O port can be set over the I2C ADDR jumpers. There is also the ENA pin, which, in indexer mode, can turn all outputs on or off. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used for further development.

H-Bridge 15 Click hardware overview image

Features overview

Development board

Clicker 4 for STM32F4 is a compact development board designed as a complete solution that you can use to quickly build your own gadgets with unique functionalities. Featuring an STM32F407VGT6 MCU, four mikroBUS™ sockets for Click boards™ connectivity, power management, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core is an STM32F407VGT6 MCU, a powerful microcontroller by STMicroelectronics based on the high-performance

Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the

development board much simpler and, thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution that can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws.

Clicker 4 for STM32F4 double image

Microcontroller Overview

MCU Card / MCU



ARM Cortex-M4

MCU Memory (KB)


Silicon Vendor


Pin count


RAM (Bytes)


You complete me!


DC Gear Motor - 430RPM (3-6V) represents an all-in-one combination of a motor and gearbox, where the addition of gear leads to a reduction of motor speed while increasing the torque output. This gear motor has a spur gearbox, making it a highly reliable solution for applications with lower torque and speed requirements. The most critical parameters for gear motors are speed, torque, and efficiency, which are, in this case, 520RPM with no load and 430RPM at maximum efficiency, alongside a current of 60mA and a torque of Rated for a 3-6V operational voltage range and clockwise/counterclockwise rotation direction, this motor represents an excellent solution for many functions initially performed by brushed DC motors in robotics, medical equipment, electric door locks, and much more.

H-Bridge 15 Click accessories image

The 28BYJ-48 is an adaptable 5VDC stepper motor with a compact design, ideal for various applications. It features four phases, a speed variation ratio of 1/64, and a stride angle of 5.625°/64 steps, allowing precise control. The motor operates at a frequency of 100Hz and has a DC resistance of 50Ω ±7% at 25°C. It boasts an idle in-traction frequency greater than 600Hz and an idle out-traction frequency exceeding 1000Hz, ensuring reliability in different scenarios. With a self-positioning torque and in-traction torque both exceeding 34.3mN.m at 120Hz, the 28BYJ-48 offers robust performance. Its friction torque ranges from 600 to 1200, while the pull-in torque is 300 This motor makes a reliable and efficient choice for your stepper motor needs.

H-Bridge 15 Click accessories 2 image

Used MCU Pins

mikroBUS™ mapper

Reset / ID SEL
Enable / ID COMM
Power Supply
I2C Clock
I2C Data
Power Supply

Take a closer look


H-Bridge 15 Click Schematic schematic

Step by step

Project assembly

Clicker 4 for STM32F4 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Clicker 4 for STM32F4 as your development board.

Clicker 4 for STM32F4 front image hardware assembly
LTE IoT 5 Click front image hardware assembly
LTE IoT 5 Click complete accessories setup image hardware assembly
Clicker 4 STM32F4 Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for H-Bridge 15 Click driver.

Key functions:

  • hbridge15_set_pins - H-Bridge 15 set pins function.

  • hbridge15_set_sleep - H-Bridge 15 set sleep function.

  • hbridge15_set_out_state - H-Bridge 15 set output function.

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

 * @file main.c
 * @brief H-Bridge 15 Click example
 * # Description
 * This example demonstrates the use of the H-Bridge 15 click board by
 * driving the motor in both directions with braking and freewheeling. 
 * The demo application is composed of two sections :
 * ## Application Init
 * Initializes the driver and performs the click default configuration.
 * ## Application Task
 * This example is driving a motor in both directions with 
 * motor braking and freewheeling in between.
 * @author Stefan Ilic

#include "board.h"
#include "log.h"
#include "hbridge15.h"

static hbridge15_t hbridge15;
static log_t logger;

void application_init ( void ) 
    log_cfg_t log_cfg;  /**< Logger config object. */
    hbridge15_cfg_t hbridge15_cfg;  /**< Click config object. */

     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    hbridge15_cfg_setup( &hbridge15_cfg );
    HBRIDGE15_MAP_MIKROBUS( hbridge15_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == hbridge15_init( &hbridge15, &hbridge15_cfg ) ) 
        log_error( &logger, " Communication init." );
        for ( ; ; );
    if ( HBRIDGE15_ERROR == hbridge15_default_cfg ( &hbridge15 ) )
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    log_info( &logger, " Application Task " );

void application_task ( void ) 
    log_printf( &logger, " Motor in forward mode. \r\n" );
    hbridge15_set_out_state( &hbridge15, HBRIDGE15_DRIVE_MOTOR_FORWARD );
    Delay_ms( 5000 );
    log_printf( &logger, " Motor brake is on \r\n" );
    hbridge15_set_out_state( &hbridge15, HBRIDGE15_DRIVE_MOTOR_BRAKE );
    Delay_ms( 2000 );
    log_printf( &logger, " Motor in reverse mode. \r\n" );
    hbridge15_set_out_state( &hbridge15, HBRIDGE15_DRIVE_MOTOR_REVERSE );
    Delay_ms( 5000 );
    log_printf( &logger, " Motor is coasting \r\n" );
    hbridge15_set_out_state( &hbridge15, HBRIDGE15_DRIVE_MOTOR_FREEWHEEL );
    Delay_ms( 2000 );

void main ( void ) 
    application_init( );

    for ( ; ; ) 
        application_task( );

// ------------------------------------------------------------------------ END

Additional Support