Arduino RPM Counter & DC Motor Constant Speed Controller

(Last Updated On: February 5, 2022)

Arduino RPM Counter Description:

Arduino RPM Counter

Arduino RPM Counter & DC Motor Constant Speed Controller- In this tutorial, you will learn how to make an RPM counter and how to automatically adjust the speed of a DC motor. In this project, the IR Sensor will be used with the Arduino Uno for the RPM measurement and a Potentiometer/Variable resistor will be used to set the RPM value. The real-time RPM value will be compared with the preset RPM value and then the Arduino will increase or decrease the speed of the DC motor automatically.

In this tutorial, we will cover,

  • The components and tools you will need for this project.
  • What is an RPM Counter?
  • Why we need DC Motor Constant Speed Controller?
  • Complete Circuit Diagram Explanation.
  • Proteus Simulation of the RPM Counter & DC Motor Constant Speed Controller.
  • Program explanation and finally
  • Practical Demonstration of the RPM counter and DC Motor Constant Speed Controller.

Without any further delay, let’s get started!!!

The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

12v CPU Fan:

Obstacle IR Infrared Sensor:

TIP122 NPN Transistor best package:

12v Adaptor:

Arduino Uno

Arduino Nano

Mega 2560:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

What is an RPM Counter or Tachometer?

RPM stands for “Revolutions per Minute”. The RPM counter is also known as the Tachometer, revolution-counter, tach, rev-counter, and RPM gauge. The RPM counter or Tachometer is an instrument or a device that is used for measuring the rotation speed of a shaft or disk of a motor or any rotating object.

There are two types of Tachometers

  • A tachometer that has contact with the rotating object, like for example an Encoder.
  • Contact-less tachometer or Optical Tachometers, these types of the tachometer or RPM counters use a laser or Infrared technology for measuring the RPM of a rotating object from a certain distance. The Optical Tachometers are becoming very famous and commonly used in vehicles and machines. The optical tachometers are now commonly used in industries for monitoring the RPM or speed of different AC or DC motors.

In this project, I have used the optical tachometer technology using an IR infrared Sensor.

Arduino RPM Counter

This is an Infrared Sensor. It has two LEDs. The white one is the Transmitter LED while the Black one is the Receiver LED. The range can be adjusted using the variable resistor.  The range of detection is also affected by the color of the object, if you place a Black color object the range of detection will decrease and for a White object, the range is increased. To get a nice reflection, use a white color sticky tap on the object surface.

Arduino RPM Counter

The Transmitted IR rays are reflected by the object and are received by the IR Receiver LED.

Why we need a DC Motor Constant Speed Controller?

DC Motors are used in industrial machines, Electric bikes, Wheelchairs, etc. There are situations when we need to run a DC motor at a constant speed, but sometimes when the load on the DC motor increases the RPM starts to reduce which can really affect the production. In a situation like this, we will need an automatic control system which can automatically adjust the RPM of the DC motor using the Pulse Width Module “PWM” Technique.

To achieve the constant speed or RPM we will need to make an optical tachometer or RPM monitor. The RPM counter or Tachometer will measure the RPM of the DC Motor in Real-Time, this RPM is then compared with the pre-set value defined in the programming and then Arduino decides whether to increase the speed of the dc motor or to decrease the speed. The adjustment value is added or subtracted as per the requirement; this is done automatically by the Arduino Uno.

Arduino RPM Counter Block Diagram:

Arduino RPM Counter

 Arduino RPM counter & Constant Speed Controller Circuit Diagram:

Arduino RPM Counter

Let’s first of all, start with the Power Supply which is based on the LM7812 and LM7805 Voltage Regulators. The 12 volts from the LM7812 are used to power up the DC Motor, while the LM7805 voltage regulator is used to power up the 16×2 LCD. In the circuit diagram, you can clearly see all the connections where the 5 volts are connected.

The connections of the 16×2 LCD with the Arduino Uno can be clearly seen. Pin number1 and Pin number16 are connected with the ground. Pin number2 and Pin number 15 are connected with the 5 volts. Pin number3 of the 16×2 LCD is connected with the middle Pin of the variable resistor, this variable resistor is used to control the LCD contrast. While the other two pins of the variable resistor are connected with the 5 volts and GND. The RS Pin of the 16×2 LCD is connected with the Arduino’s Pin number7. Pin number5 which is the R/W pin of the LCD is connected with the ground. The Enable pin of the LCD is connected with Pin number8 of the Arduino Uno. The data pins D4 to D7 of the LCD are connected with the Arduino’s Pins 9, 10, 11, and 12.

There is another variable resistor given at the bottom, its middle Pin is connected with the Arduino’s Analog Pin A0. This variable resistor is used to set the Pre-set value. This variable is used to tell the controller that at which RPM we want to keep the motor speed constant. The real-time RPM is compared with this value.

On the right side, as you can see, the IR Sensor VCC and GND are connected with the Arduino’s 5 volts and ground. While the OUT Pin of the IR Sensor Module is connected with the Arduino’s External Interrupt Pin 2.

The Motor driver circuit is build using TIP122. This transistor is selected due to its ability to handle currents more than 2Amps. A motor is then connected between the +v supply wire and collector of the TIP122 and a 10k ohm resistor is connected at the base of the TIP122 as its BJT a current-controlled device, and another end of the 10k ohm resistor is connected to the PWM pin of the Arduino as per the programming. So that’s all about the Circuit diagram.

 Arduino RPM Counter & DC Motor Constant Speed Controller Programming:

Optical Tachometer or RPM Counter & DC Motor Constant Speed Controller Simulation:

Before I start the soldering I always check my connections in simulation software like Proteus, and once I am satisfied with the results then I start the practical connections.

Arduino RPM Counter

Download Simulation of Arduino RPM counter & DC Motor Constant Speed Controller: simulation

For the practical demonstration watch video given below. This is an old video which I recorded a long time ago, sorry for the video quality. The same project is also known as the frequency locked loop DC Motor Speed Controller.

Arduino RPM Counter Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...


  1. It’s a great effort you are helping students. I’m trying to find hex file simulation plz guide me in this regard.

  2. Hello. I’ve been trying to use your code but instead of using an Infrared sensor I want to use a Hall Effect sensor. I don’t know where I’m going wrong?

    int sensePin = 2; // hall effect sensor
    int motorPin = 9; // Motor is connected here

    volatile byte rpmcount;
    unsigned int rpm;
    unsigned long timeold;
    int incmspeed = 25; // default motor speed

    byte val = 1500;

    void rpm_fun()

    void setup()
    pinMode(sensePin, INPUT);

    attachInterrupt(0, rpm_fun, FALLING);

    rpmcount = 0;
    rpm = 0;
    timeold = 0;

    void loop()



    rpm = 601000/(millis() – timeold)rpmcount; // thirty means that the motor blade cuts the sensor two times. so its gonna be half. if the motor blade

    timeold = millis();
    rpmcount = 0;

    attachInterrupt(0, rpm_fun, FALLING);

    if( rpm < val )
    incmspeed = incmspeed + 10;

    incmspeed = incmspeed – 10;
    // new addition
    if ( incmspeed < 1)
    incmspeed = 0;
    if( incmspeed > 254)
    incmspeed = 255;

    analogWrite(motorPin, incmspeed);

    1. Thanks for this, extremely helpful!!


      Without going into your code, have you used a pull-up resistor to 5V? you will need to with most Hall effect FG outputs.


Leave a Reply

%d bloggers like this: