How to control dc motor with Arduino

Hey guys, welcome back to Techatronic. We are sharing today how to control dc motor with Arduino? this will go to be very simple. In this article, you will learn something definitely. We are going to share every single step and all information that is necessary to make it possible. in robotics, we use dc motor in many projects. like robotics car, Smart irrigation system.

control dc motor with Arduino


Controlling the motion of any device or any locomotive is a very complicated and big task especially when it is for automation Today we’ll tell you how you can control a motor using Arduino and a motor driver. The driver for the motor is necessary as to drive the motor with its maximum power we have to send a signal to the driver and this can be done with the help of an l298n motor driver. Motor drivers and motors come with various rpm and power ratings so choose them wisely for better compatibility.

The two we are going to use in very famous and widely available in the market are l298n motor driver and l293d and both are necessary for control dc motor with Arduino? the motor driver which is compatible with BO geared motors and various other small ones. we must take an example to understand better if are using 4 motors in an RC car the Arduino can’t operate these all four motors. because Arduino only can give low current on 3.3-5v at each port.


In this project, the main part is Arduino UNO which is the heart of the project and for movement control, we are using L298N and L293D motor drivers which are used due to their h-bride for motor driving also two signal wires for bi-direction movement. L298N is a 15 pin ic whose pinout is attached below for further reference. It comes in two packages Multiwatt-15 and powerSO20 which are for different purposes. The internal schematic of IC is a bit complicated but as a whole, it uses a combination of 4, not gates along with 2-PNP and 2- NPN transistors in two sets to control two motors simultaneously. This IC provides pins for variable power supply which is used to drive motor, i.e., if we power ic by 5v and supply voltage by 12v then motor will run on 12v but the logic in ic will be controlled at 5 v.

Due to heat generation at the time of driving motor to describe it a heat sink is attached to the icon module to provide efficient heat dissipation

Similarly, L293D is a 16 pin IC that also works on the same as L298N but has a change in its package type.




the schematic diagram for L39d driver

the schematic diagram for L39d driver 

 the schematic diagram for the L298n driver

the schematic diagram for L298n driver 


  • Used to drive almost all small motors
  • Easy to understand and use
  • Good heat dissipation
  • Low price





  • Any microcontroller preferably Arduino Uno for beginners.
  • An L298N or L293D module
  • A BO geared motor
  • Jumper wires
  • 220ohm resistor
  • A buzzer

Arduino motor control  circuit diagram,

Arduino with  L293d driver circuit

arduino with l293d circuit

Arduino with L298N circuit


Connect BO geared motor, Arduino, and motor modules with each other according to the schematic in the above diagrams

DC motor Arduino Code: –

 //put this code in the ide of Arduino from this line  
       void setup()  
       void loop()  
       digitalWrite(13,HIGH); // Clock wise direction of motor  
       digitalWrite(13,LOW); // Anti clock wise direction of motor  

Arduino dc motor working: –

Now, we will see how the dc motor Arduino control system works? Arduino always sent 3.3v to 5v to the output port with the less amount current. so it is not possible to operate the motor directly so we need something to amplify the current and the voltage in the circuit. and if we connect the motor direct then it can damage the Arduino board due to the back emf. which can be generated. so, these both are the reason to attach a motor driver to control a dc motor with Arduino.  The code is very simple in the setup section we initialize the signal pins of the module, and in the loop section, we turn pins high and low turn by turn to rotate the motor clockwise and anti-clockwise.

as you are seeing the code above let me explain the code for you so that you can understand it better. first of all, we need to initialize and set up the pin. which we are using in this project for example if are going to use pin 4 of Arduino then we will write like “pinMode(4, OUTPUT) ” this is the terminology uses in the Arduino coding to recognize the Arduino that we are using which pin. and now next is to send the instruction to send HIGH or LOW to the pin. For example, if we are sending HIGH on pin 4 then the Arduino will send a 3.3v to 5v power supply at that pin. and we will write it like” digitalWrite(4, HIGH); ” digitalWrite is terminology to Send HIGH or LOW to the Digital pin.

Learn 10+ basic activity & sensor interfacing with our Arduino ebook. Well explained program. And brief circuit diagram WhatsApp and email support. which will help you to learn basic electronics, Arduino Coding, Sensor interfacing with Arduino, Arduino, and much more. buy Arduino Ebook to learn

2 thoughts on “How to control dc motor with Arduino”

Comments are closed.