dc motor speed control

DC Motor Speed Control Using Arduino | Arduino Tutorial

Arduino Projects


Hello geeks, welcome back to Techatronic. In this article, we are going to teach you a very interesting project that is how to make a DC motor speed control circuit using Arduino UNO. We are using an L298N motor driver module here for interfacing with the DC motor. You can not regulate the speed of a DC motor directly but using this circuit it is possible to do so. Complete the circuit and then upload the code to the Arduino. You can also check more such amazing projects based on Arduino and IoT. The image of the complete project is also given below.

dc motor speed control

DC Motor Speed Control Working

Generally, DC motors rotate at a constant speed(RPM) in clockwise or anticlockwise directions depending upon the polarity of the current that is provided to it. In this project, we are trying to slow down or boost the speed of the motor with the help of an Arduino board. The potentiometer that we are using is responsible for the speed of the motor. You can rotate the potentiometer and the speed of the motor varies accordingly. this is the 10th blog in the Arduino tutorial. The Arduino generates control signals based on the input from the variable resistor but the motor can not process them directly so we are using an L298N motor driver. This driver module provides the correct output signals so the motor can rotate perfectly. You can check the output values generated by the variable resistor on the serial monitor screen. The screenshots of the serial monitor screen are also given below so that you can locate it on your IDE software.


Serial Communication simulation

Components Required

dc motor speed control

  • Arduino UNO
  • DC motor
  • Jumper wires and a breadboard
  • 9 volts battery
  • 10K potentiometer
  • L298n motor driver
  • USB cable for uploading the code
  • Breadboard
  • Jumper wire


Components Table

S.No Component Required Quantity Buy Link
1. Arduino UNO 1 https://amzn.to/3ue2vmh
2. Arduino UNO Cable 1 https://amzn.to/3obXjht
3 L298N Motor Driver 1 https://amzn.to/3CSzX4L
4. 9 Volt Battery 1 https://amzn.to/3zUDj5l
5. DC Motor 1 https://amzn.to/3a5YDKR
6. 10k Potentiometer 1 https://amzn.to/3kSxmlc
7. Jumper Wire 40 https://amzn.to/39q43jr
8. Breadboard 1 https://amzn.to/39vsRX2

DC Motor Speed Control Circuit Diagram

dc motor speed control circuit


Connection Table

Arduino UNO 10 K Potentiometer
VCC Terminal 1
A0 Pin Terminal 2
GND Terminal 3
Motor L298N Motor Driver
Terminal 1 Terminal 1 Output
Terminal 2 Terminal 2 Output
Arduino UNO 9 Volt Battery L298N Motor Driver
Positive +12
( +5V ) VCC + 5
GND Negative GND
9 Pin IN 1
8 Pin IN 2

Connect 5 volts pin of the Arduino with the 5 volts pin of the L298n motor driver module and one side pin of the 10K ohm potentiometer. Attach the GND pin of the Arduino with the GND pin of the L298n module and another side pin of the 10K potentiometer. Join the middle pin of the potentiometer with the analog-0 pin of the Arduino. Take a 9 volts battery and connect its positive wire with the 12 volts pin of the L298n module and its negative wire with the GND pin of the Arduino. Join the IN1 pin of the motor driver module with the digital-4 pin of the Arduino and the IN2 pin of the driver module with the digital-3 pin of the Arduino. At last, take a DC motor and connect its wires with the output pins of the driver module. The circuit is now completed, power the Arduino and DC motor start rotating.

DC Motor Speed Control Arduino Code

NOTE: Please upload the code which is given below to the Arduino.

 void setup()   
   pinMode(3,OUTPUT); // Motor pin 1   
   pinMode(4,OUTPUT); // Motor pin 2   
   digitalWrite(4,LOW); // Normally LOW inthis pin   
   pinMode(A0,INPUT);  // 10k Potentiometer   
  void loop()   
  int s=analogRead(A0); // 10k Potentiometer   
  int z=map(s,0,1024,0,255);   

We hope that you like this project on DC motor speed control and now try to make it on your own so that you can understand it better. If you have any doubts regarding this project then do inform us in the comments section below. Also, check out the latest tutorials on Arduino and Raspberry Pi.


Video Sample

Spread the love, Share this post with friends

1 thought on “DC Motor Speed Control Using Arduino | Arduino Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *