DIY Brushed Motor ESC Using Arduino and L298N H-Bridge

Introduction: DIY Brushed Motor ESC Using Arduino and L298N H-Bridge

About: I am an 17 year old living in Istanbul, Turkey who has been electronics and artisan crafts for 10 years. I especially like woodworking, LED, and electric motor projects. I am also an active web programmer and …

Arduino-compatible modules and remote control-compatible modules are quite differently made, especially in what communication protocols they use. An Arduino-compatible module such as L298N receives on and off signals and is really best controlled by programmatically sending these signals to its inputs. Meanwhile, the signals used for RC equipment, pulse position modulated (PPM) signals, are designed to control servo motors by sending numbers encoded in a serial fashion. The conversion between these are better done using a manufactured circuit called ESC (electrical speed controller); however, although ESCs for brushless motors are easy to find and cheap, it is apparently not the case for brushed motor. I could only find a single brushed ESC model that costed twice the cost of an average brushless ESC.

Fortunately, I had more toys to play with. The L298N module and the Arduino Pro Mini which I have a lot of experience with are both dirt cheap and not too complicated to assemble a circuit of this kind with. A had some code from the Destination Imagination challenge I participated in a couple of years ago and had these parts ready to waste, so I was happy to put this together for a good friend of mine. If that's enough rationale, we can begin.


  • L298N H-bridge Breakout Board
  • Arduino Pro Mini clone (or other Arduino Uno-compatible board)
  • Another Arduino (preferably some junk Uno) to program the Pro Mini
  • female-female and male-female breadboard jumper wire
  • 9V battery socket (or other, according to your motor voltage needs)

Note that the circuit is designed having a FlySky IA6B radio receiver in mind. It should be a generic-enough receiver, but make sure if your receiver has specific requirements for connected devices. Comment below if you have questions.

Step 1: Prepare Your Boards

Solder pins on your Arduino Pro Mini. Soldering pins

  • on either programming header or pins reset, 11, 12, 13 (to program the board)
  • on pin 9
  • on pin 13 :p
  • on pin 2
  • all VCC pins, including the ones in programming pins
  • all GND pins, including the ones in programming pins

is enough; however, I recommend soldering on all pins so you can use the Arduino for other projects.

There is no preparation necessary for the L298N board. At least make sure the two-pin jumpers are still on there.

Step 2: Connect Everything

Make the following connections with female-female jumper cables.

  • Pin 13 of Arduino goes to EN1 of L298N
  • A GND pin of Arduino goes to IN1 of L298N
  • Pin 9 of Arduino goes to IN2 of L298N

The following connections are a bit more involved.

  • Cut one end of a jumper so you have a naked-female jumper wire. Remove the insulation from the naked end and twist around/solder with the battery socket's negative end. Put this joined end in the L298N's ground terminal. Connect the female end to one of the Arduino's remaining GND pins.
  • Put the battery socket's positive end in L298N's 12V terminal.
  • Put the male end of a male-female jumper in L298N's 5V terminal and connect the female end to one of Arduino's VCC pins.
  • Separate a yellow-red-brown group of female-female jumper. This will connect to the receiver. Connect one brown end to the Arduino's free GND pin, one red end to the free VCC pin, and one yellow end to pin 2.

Before programming, disconnect the jumper cable coming from L298N's 5V!

Step 3: Program the Arduino

WARNING! Before programming, disconnect the jumper cable coming from L298N's 5V!

Follow these instructions (pins reset, 11, 12, 13) or these instructions (programming header) to program your Arduino Pro mini or compatible. The sketch is here and is also attached as a file.

Also, I used this board core to enable programming the Pro Mini using the Arduino IDE.

PPM to PWM Conversion Program for Arduino Pro Mini

* 2019 Boraini.
* All permissions are hereby granted to the end user. Use at your own risk.
//pin definitions. Using pin 2 is mandatory since it is the hardware interrupt pin of Pro Mini.
//RX pulse separation in microseconds
//interval between motor output updates
//volatile declarations are necessary to be able to manipulate the values during an interrupt.
unsignedvolatilelong sigStart; //32 bits
unsignedvolatileshort sig; //16 bits
bool bin; //Logical
voidsetup() {
//RX reading is available in serial for convenience.
pinMode(RX_PIN, INPUT);
//enable L298N
digitalWrite(ENABLE_PIN, HIGH);
//we detect both the rising and falling edges of the RX signal
attachInterrupt(digitalPinToInterrupt(RX_PIN), calcThrottle, CHANGE);
//this somehow works
voidcalcThrottle() {
if (digitalRead(RX_PIN))
//begin counting
sigStart = micros();
//end counting
sig = (micros() - sigStart);
voidloop() {
//we disable interrupts "just in case"
analogWrite(OUT_PIN, map(sig, MINSIGNAL, MAXSIGNAL, 0, 255));
//this doesn't block the readings since we use interrupts. Yay!
view rawPWMtoPPM.ino hosted with ❤ by GitHub

Step 4: Connect Your ESC to Your Vehicle

Connect the motor to L298N's left hand side motor output terminal, when looking from the side of power terminals.

Connecting to the receiver might be troublesome. The ESC will connect like a servo, and will also power the receiver if you don't remove the jumpers. The red power cable will go to the middle pin, the yellow signal to the notched side pin, and the brown ground cable to the other pin. If you don't see a notch look for a label on the receiver packaging. If you don't see a label, well, good luck. :)

If you are using an airplane-oriented radio receiver, you will connect all receiver cables in the desired channel. If you have a quadcopter-oriented radio receiver, however, you might have a separate battery channel. If the latter is the case for you, connect the red and brown wires to that channel and the yellow cable to the desired channel.

(I guess you can power a quadcopter radio receiver from all channels, but I am not sure or can try right now.)

Be the First to Share


    • Furniture Contest

      Furniture Contest
    • Box Challenge

      Box Challenge
    • Home Decor Challenge

      Home Decor Challenge