Arduino Nano ESP32 - BTS7960 Motor Driver
In this guide, we will learn how to control a large 12V DC motor from the Arduino Nano ESP32 with a BTS7960 motor driver module. Here is a project to keep in mind: the roof vent of a greenhouse. On a hot afternoon, a gear motor pushes the window open to let the heat out. In the evening, it pulls the window shut again. A motor that lifts a window can need more current than a small driver can give, so the BTS7960 is a good match. And since the Nano ESP32 has WiFi built in, the same vent could later be opened and closed from a web page. In detail, we will learn:
- A tour of the BTS7960 module, and what every one of its eight control pins is for.
- How to wire the module to the Nano ESP32, and why its VCC pin goes to VBUS (5V).
- How the two PWM pins and the two enable pins set the direction and the speed, and how they stop the motor hard or let it roll.
- How a short sketch speeds the motor up, brakes it, runs it backward and then lets it roll to a stop.

Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of BTS7960 Motor Driver
The Nano ESP32 can decide when a motor runs, but its pins cannot power the motor. Each pin gives 3.3V and only a small current. The BTS7960 module takes over that heavy part. On the upper face of the PCB you find two Infineon BTS7960B power chips. A large heat sink, bolted underneath, keeps them cool. Each chip looks after one of the two motor wires, and it switches that wire between the + and the - of the supply. Together, the two half-bridges make one full H-bridge. So you can run one brushed DC motor both ways, and the duty cycle of a PWM signal decides the speed (bigger duty cycle, faster motor). Compared with an L298N or a DRV8833, this driver plays in a heavier class. It is built for loads like wiper motors, winches, scooter or wheelchair motors, large gear motors and heavy robots. In online shops, you may find it listed as "IBT-2" or "HW-039".
| BTS7960 Module | |
|---|---|
| Motor supply (B+ and B-) | 5.5V to 27V DC (6V, 12V and 24V motors) |
| Motor current | up to 43A (the current limit of the chip) |
| Motors | one brushed DC motor, both directions |
| PWM frequency on RPWM and LPWM | up to 25 kHz |
| Logic chip | 74HC14 buffer, powered by the VCC pin |
| Protection | current limiting, over-temperature |
| Extra outputs | R_IS and L_IS (current sense / fault signal) |
Read the 43A as a ceiling, not as a working value. Once the current gets near that value, the chip begins to hold it back. A vent motor may run for many seconds at a time, so pick a motor that draws far less. For a long run, the real limit is how much heat the heat sink can carry away.

Eight male pins stand in two rows on the control header. Pins 1, 3, 5 and 7 (RPWM, R_EN, R_IS, VCC) form one row. Pins 2, 4, 6 and 8 (LPWM, L_EN, L_IS, GND) form the other, so RPWM faces LPWM, R_EN faces L_EN, and so on. Two labels on the board look odd: the silkscreen says R_S where it means R_IS, and L_S where it means L_IS. The signals do not go straight to the power chips. They first pass a 74HC14 buffer chip, which the product page calls the isolation chip. The pins one by one, and where each goes in this guide:
- RPWM pin: speed signal for the forward direction. It drives the right half-bridge. Connect to D9 of the Nano ESP32.
- LPWM pin: speed signal for the reverse direction. It drives the left half-bridge. Connect to D10.
- R_EN pin: the enable of the right half-bridge. At HIGH that half works, at LOW it rests. Connect to D12.
- L_EN pin: works like R_EN, but for the left half-bridge. Connect to D11.
- R_IS / L_IS pins: give out a current-sense or error signal. Not needed here, so leave them free.
- VCC pin: the supply of the logic side only (the 74HC14 chip plus the power LED). No motor current comes from it. Connect to VBUS (5V).
- GND pin: connect to GND. Inside the module, it is tied to B-.
- B+ / B- screw terminals: where the 12V for the motor comes in, + on B+ and - on B-.
- M+ / M- screw terminals: hold the motor's two wires.
How the four control pins move the motor
First, both enable pins are HIGH. Then RPWM and LPWM choose the motion:
| RPWM | LPWM | What the motor does |
|---|---|---|
| PWM (0 to 255) | 0 | turns forward, the duty cycle sets the speed |
| 0 | PWM (0 to 255) | turns in reverse, the duty cycle sets the speed |
| 0 | 0 | brakes - the driver joins the two motor wires, so it stops fast |
There is a fourth state. Pull both enable pins LOW, and the two half-bridges switch off. Now no power flows to the motor. The shaft coasts: it keeps turning and slows down on its own. When you write your own code later, remember this: either RPWM or LPWM has to be 0 at every moment. Giving PWM to both together is not allowed.
Power and ground
- VCC goes to VBUS, which carries 5V while the Nano ESP32 runs on USB. A single buffer chip is all that VCC powers. The module maker gives 5V as its supply. Its inputs accept 3.3V levels, so the Nano ESP32 pins can drive them as they are.
- Nothing is plugged into R_IS and L_IS, and the four inputs have pull-down resistors. So the module sends nothing back to the Nano ESP32, and 5V can never reach one of its pins.
- On the module, the GND pin is already connected to B-. Because of that, one GND-to-GND wire between the two boards also shares the ground with the 12V side. You do not run a wire to B-.
- B+ and B- bring the 12V from the adapter to the motor. Choose an adapter rated for more current than your motor draws.
※ NOTE THAT:
B+ carries 12V: keep it away from every pin of the Nano ESP32. Also find out which adapter wire is + and which is - before the power goes on. If they are swapped, the module can break.
Wiring Diagram
The module has two sides. From the control header, six jumper wires run to the Nano ESP32: four signals, plus VBUS and GND. On the screw terminal side, the DC power jack passes the 12V from the adapter to B+ and B-, while M+ and M- take the motor wires. The Nano ESP32 itself runs from the USB cable and never touches the 12V. Any digital pin of the Nano ESP32 can make PWM, so we use four pins that sit side by side on one header: D9, D10, D11 and D12.

This image is created using Fritzing. Click to enlarge image
| BTS7960 Pin | Arduino Nano ESP32 Pin / Other |
|---|---|
| RPWM | D9 |
| LPWM | D10 |
| R_EN | D12 |
| L_EN | D11 |
| VCC | VBUS (labelled 5V on the screw terminal board) |
| GND | GND |
| R_IS, L_IS | leave unconnected |
| B+ | + of the 12V adapter (through the DC power jack) |
| B- | - of the 12V adapter (through the DC power jack) |
| M+, M- | the two wires of the 12V DC motor |
Pushing jumper wires into the headers is quick, but the wires can slip out. Simply plug the Arduino Nano ESP32 into a Screw Terminal Expansion Board for Arduino Nano. The diagram below shows the same wiring with the screw terminal board.

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
Keep the 12V adapter unplugged while you wire. Plug it in last, after the Nano ESP32 is wired and the code is uploaded. The enable wires are easy to mix up: R_EN belongs on D12, L_EN on D11.
How To Program For BTS7960 Motor Driver
Nothing needs to be installed. The sketch uses only analogWrite() for the two PWM pins and digitalWrite() for the two enable pins.
- Name the four control pins:
- Inside setup(), every control pin becomes an OUTPUT. Write 0 to RPWM and LPWM before anything else, then set both enables HIGH to wake up the driver:
- Forward, with speed as a value between 0 and 255:
- Turn in reverse. Just swap the roles of the two PWM pins:
- Brake. Write 0 to RPWM and to LPWM, and keep the enables HIGH:
- Coast. Both enable pins go LOW, so the half-bridges switch off:
Why does the brake use analogWrite(pin, 0) and not digitalWrite(pin, LOW)? On the Nano ESP32, a pin that has run analogWrite() stays in PWM mode. So the sketch keeps each pin on one function only: PWM for RPWM and LPWM, plain HIGH and LOW for R_EN and L_EN.
Arduino Nano ESP32 Code - BTS7960 Motor Driver
The full sketch wraps the steps above in five small helpers: driverOn(), motorForward(), motorReverse(), motorBrake() and motorCoast(). One round takes about 12 seconds: speed up forward, hold full speed, slow down, brake, run backward at half speed, and coast. Then the sketch turns the driver on again and starts over. For every step, a line shows up in the Serial Monitor. The lines borrow the greenhouse picture: forward is "Open vent", and reverse is "Close vent".
Detailed Instructions
Follow these instructions step by step:
- New to the Arduino Nano ESP32? Get the Arduino IDE ready first with how to setup environment for Arduino Nano ESP32 on Arduino IDE.
- Wire everything as in the table above. Leave the 12V adapter unplugged for now.
- Connect the Nano ESP32 to your PC with the USB Type-C cable.
- Launch the Arduino IDE on your computer.
- Select the appropriate Arduino Nano ESP32 board (e.g., Arduino Nano ESP32) and COM port.
- Paste the code above into a new sketch, then click the Upload button. You do not need to install any library.
- When the upload has finished, plug the 12V adapter into the DC power jack.
- Open the Serial Monitor at 9600 baud. Then watch the motor and compare it with each new line.
Pay attention to the two stops. At the "Stop" line, the shaft stops almost at once, because the driver joins the motor wires. At the "Idle" line, the driver is off, so the shaft keeps turning for a moment and slows down by itself. For a greenhouse vent, the brake is the better choice, because the window stops close to the spot where you cut the power. If the "ready" line is missing, the Serial Monitor simply opened a little late. The other lines keep coming.
※ NOTE THAT:
- Does the motor turn the wrong way during the "Open vent" lines? Unplug the 12V adapter and swap the M+ and M- wires.
- Do the lines appear, but the motor does not move? Check the 12V adapter, the GND wire between the two boards, and that R_EN is on D12 and L_EN on D11.
- A hum or a whine at low speed is normal. analogWrite() on the Nano ESP32 makes a PWM of about 1 kHz, and your ears can hear that.
Is the BTS7960 too big for your motor? For small motors, see Arduino Nano ESP32 - DRV8833 DC Motor Driver or Arduino Nano ESP32 - DC Motor, which uses the DRV8833 too. The DRV8833 handles two motors, about 1.5A for each, up to 10.8V. The BTS7960 has room for just one motor, yet it takes far more current and up to 27V.