Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To control two brushed DC motors with an STM32 and an L298N, connect one motor across OUT1–OUT2 and the other across OUT3–OUT4. Use two logic inputs per motor to set direction and the corresponding enable input for on/off control or PWM speed control. Power the motors from a suitable motor supply, connect STM32 ground to driver ground, and check the exact module’s pinout, regulator configuration, and current and thermal limits before applying power.

How the STM32 and L298N work together

The L298 contains two full H-bridges. Bridge A controls the motor connected between OUT1 and OUT2; Bridge B controls the motor between OUT3 and OUT4. For each bridge, two logic inputs select the output polarity, while its enable input turns that bridge on or off. Applying PWM to an enable input is a common way to vary the motor’s average drive.

ST describes the L298 as a dual full-bridge driver for inductive loads, including DC motors, that accepts standard TTL logic levels. The chip does not provide a ready-made STM32 pinout: the exact connections and board features depend on the L298N module or breakout you have.

Connections to make

Motor outputs and control inputs

  • Connect motor 1 across OUT1 and OUT2; connect its direction signals to IN1 and IN2 and its enable signal to ENA.
  • Connect motor 2 across OUT3 and OUT4; connect its direction signals to IN3 and IN4 and its enable signal to ENB.
  • Use two STM32 GPIO outputs for each motor’s direction inputs. Use a timer PWM output for each enable input if you want independent speed control.

Module labels commonly follow this scheme, but terminal placement, jumper functions, onboard regulator wiring, and the available logic-supply connection vary. Follow the schematic or documentation for the specific board rather than assuming every module is wired alike.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Power and ground

  • Connect the motor supply to the board’s motor-supply input, using a voltage suited to the motor. Do not power a motor from an STM32 GPIO pin.
  • Connect STM32 ground to L298N ground so both devices use the same signal reference.
  • Before connecting a logic supply, check the board documentation and regulator-jumper configuration. A module’s 5 V pin is not necessarily a logic-supply input, and regulator arrangements differ.

ST’s L298 datasheet calls for a 100 nF non-inductive capacitor between VS and ground and another 100 nF between VSS and ground. Check whether the chosen board includes these capacitors and the recirculation-diode arrangement shown in the datasheet application circuit.

Check 3.3 V logic compatibility

ST’s L298 datasheet lists VSS, the logic supply, as 4.5–7 V in its electrical-characteristics table. It specifies a minimum input-high threshold of 2.3 V and an input voltage up to VSS. That threshold indicates a 3.3 V STM32 output may be recognized as high, but it does not establish compatibility for every STM32 pin and module combination. Check the selected MCU pin’s guaranteed output level and electrical limits, plus the module’s signal routing, before connecting them.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Set direction and speed in firmware

For each bridge, opposite input states command opposite motor directions. Equal input states produce a stopped, braked, or recirculating state depending on the operating mode and board circuit. Do not assume that “both low” or “both high” has the same stopping behavior across every configuration.

  1. Configure two STM32 GPIOs per motor as outputs and set them to the desired direction state.
  2. Configure a timer channel connected to ENA or ENB for PWM if variable speed is needed; consult the STM32 board documentation for the available timer pins and alternate functions.
  3. Set the PWM duty cycle to adjust the drive interval, while checking motor behavior and driver temperature under the actual load.
  4. If the application requires a safe reversal, disable the bridge before changing direction inputs, then re-enable it using the intended control sequence.

Exact timer pin names and safe reversal timing depend on the STM32 model, board revision, motor, and application; the steps above describe the control arrangement, not a tested firmware implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Understand current, voltage drop, and heat

Do not treat the L298 product page’s headline “4 A” total DC-current figure as a continuous per-channel rating. ST’s product page lists operating supply voltage up to 46 V and total DC current up to 4 A, but the datasheet distinguishes per-channel limits and their conditions.

Datasheet figure What it means
2 A per channel, DC operation Absolute-maximum output-current rating, not a recommended continuous design target.
2.5 A per channel, repetitive peak Permitted only under the datasheet’s stated 80% on/20% off condition.
3 A per channel, non-repetitive peak Specified for 100 ms; not a continuous rating.
Up to 3.2 V total output saturation drop at 1 A; up to 4.9 V at 2 A Datasheet values under its stated test conditions. The drop reduces voltage available to the motor and dissipates power as heat in the driver.

These figures are from STMicroelectronics’ L298 datasheet, DS0218 Rev 5, October 2023. Absolute-maximum ratings describe stress limits, not operating points to target. A module’s practical capability also depends on its PCB copper, heatsink, diode selection, regulator layout, and thermal path; do not infer that two channels can each run at a particular current continuously from a “4 A total” label.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Before choosing a driver, check the motor datasheet for startup and stall current as well as normal running current. Account for supply voltage, duty cycle, ambient temperature, heatsinking, and the thermal behavior of the complete module. A high bridge voltage drop can leave a motor with less voltage than the supply and can make the driver run hot.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When to consider a different STM32 motor board

If you want a board designed for the STM32 Nucleo ecosystem, ST’s X-NUCLEO-IHM04A1 is a possible alternative to compare. It uses an L6206, not an L298N, and ST lists an 8–50 V maximum voltage range and phase current up to 2.8 A rms. Those ratings are not directly comparable to L298N module figures without matching their measurement conditions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

For any candidate, compare motor voltage range, continuous and peak current conditions, bridge voltage drop and heat, logic thresholds and supply arrangement, protection and current sensing, heatsinking and PCB thermal design, connector compatibility, and available board documentation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.