How to Interface LM393 Speed Sensor with Arduino?

Table of Contents

In this project, I will talk about LM393 Speed Sensor Module, how this module works and helps in determining the speed of a rotating object and finally I will show you how to Interface LM393 Speed Sensor with Arduino and measure the speed of a motor.


A speed sensor is a type of tachometer that is used to measure the speed of a rotating object like a motor. I have already implemented a CONTACTLESS DIGITAL TACHOMETER but that was using 8051 Microcontroller.

There are many types of Speed Sensor like Hall-effect based sensors, Magnetoresistive Speed Sensor, Eddy Current based speed sensor, etc. In this project, I have used a pretty inexpensive Infrared based Speed Sensor.

Irrespective of the type of implementation, all speed sensor serves the same purpose: help us determining the rotational speed of a rotating object.


A Brief Note on LM393 Speed Sensor Module

In order to measure speed of a motor using Arduino, I have used an LM393 Speed sensor with Arduino. The LM393 Speed Sensor Module is basically an Infrared Light Sensor integrated with LM393 Voltage Comparator IC.

The following image shows the speed sensor module I have used.

Interfacing LM393 Speed Sensor with Arduino Sensor Front

If you are familiar with the designs of sensor, then this sensor can also be divided into two parts: the sensor part and the control part.

The sensor part of the LM393 Speed Sensor module consists of an Infrared LED and an NPN Photo Transistor. These two components are placed facing each other is a special housing made of black thermoplastic.

This special housing ensures that the Photo Transistor receives light only from the Infrared LED and all the external source of light is eliminated.

Interfacing LM393 Speed Sensor with Arduino Sensor Back

Coming to control unit, it is made up of LM393 Voltage Comparator and a few passive electronic components. The signal from the photo transistor is given to the LM393 and based on the presence or absence of an object between the Infrared LED and the Photo Transistor, the Output of the LM393 IC will either be HIGH or LOW.

More details is explained in the working.

Schematic of LM393 Speed Sensor Module

If you are interested in understanding the LM393 Speed Sensor Module a little bit more, then its schematic might be helpful. The following image shows the schematic of the LM393 based Infrared Sensor that is used as a speed sensor in this project.

Interfacing LM393 Speed Sensor with Arduino LM393 Sensor Schematic

Interfacing LM393 Speed Sensor with Arduino

As mentioned earlier, the main aim of this project is to measure the rotational speed of a motor using an Arduino. In order to measure the speed of a rotating device like a simple DC Motor for example, we need a special device like a speed sensor.

So, interfacing an LM393 Speed Sensor with Arduino would be helpful for the project. This interface can also be useful in several robotic application that are implemented using Arduino as the main controller.

Circuit Diagram

The circuit diagram for the interface of LM393 Speed Sensor with Arduino is shown in the following image.

Interfacing LM393 Speed Sensor with Arduino Circuit Diagram

Components Required

  • Arduino UNO [Buy Here]
  • LM393 Speed Sensor Module
  • 16×2 LCD Display [Buy Here]
  • 5V Geared DC Motor
  • Encoder Wheel
  • Speed Controller for Motor (Optional)
  • Connecting Wires
  • Breadboard

Circuit Design

First, connect the VCC and GND of the LM393 Sensor to +5V and GND of Arduino. The OUT or SIG pin of the sensor is connected to Pin 11 of Arduino.

Coming to the LCD, its RS and E pins are connected to Pins 7 and 6 of Arduino. The data pins D4 – D7 are connected to Pins 5, 4, 3 and 2 of Arduino.

Rest of the connections are as per the circuit diagram.

I have made a small setup with a piece of cardboard to fix the LM393 Sensor and Mount the Encoder Wheel on the top so that the wheel passes through the gap provided in the housing i.e. between the Infrared LED and NPN Photo Transistor.

Interfacing LM393 Speed Sensor with Arduino Sensor Encoder Wheel

The encoder wheel consists of 20 holes (this number becomes important in the program part).


The code for the project how to Interface LM393 Speed Sensor with Arduino is given below.


#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int sensor = 11;
unsigned long start_time = 0;
unsigned long end_time = 0;
int steps=0;
float steps_old=0;
float temp=0;
float rps=0;
void setup()
lcd.begin(16, 2);
lcd.print( STEPS – 0);
lcd.print( RPS – 0.00);
void loop()
lcd.print( );
lcd.print( );



The encoder wheel (wheel with holes as shown in the image) is fixed to the geared motor and is placed in the slot of the sensor. Since the wheel is fixed to the motor, one rotation of the motor implies one rotation of the wheel.

Coming to the sensor, the Infrared LED and the NPN Photo Transistor are placed directly facing each other. When there is no object in the slot, the light from the Infrared LED always falls on the Photo Transistor.

Now, as I have mentioned that the wheel has 20 holes in it, so whenever the wheel makes one rotation, the infrared light from the IR LED is obstructed for 20 times from falling on the photo transistor.



Similar Articles & Blogs

Explore similar articles on various electronics and electrical topics – 

Analogue to Digital Converter

Analogue-to-Digital Converters, (ADCs) allow micro-processor controlled circuits, Arduinos, Raspberry Pi, and other such digital logic circuits to communicate with the real world. In the real

Learn More >>

Transmission Gate

The analogue switch is a solid-state semiconductor switch that controls the transmission path of analogue signals. The open and closed operations of the switch positions

Learn More >>

Binary Adder

Another common and very useful combinational logic circuit which can be constructed using just a few basic logic gates allowing it to add together two

Learn More >>

Bus Transceiver

A Transceiver can be used to provide bidirectional, input or output control, of either digital or analogue devices to a common shared data bus. Unlike the buffer,

Learn More >>

Digital Comparator

Digital or Binary Comparators are made up from standard AND, NOR and NOT gates that compare the digital signals present at their input terminals and produce an output depending upon

Learn More >>

Binary Subtractor

As their name implies, a Binary Subtractor is a decision making circuit that subtracts two binary numbers from each other, for example, X – Y to find the resulting difference between

Learn More >>