Contents

Interfacing LM393 Infrared Speed Sensor with Arduino

LM393 Sensor Features

The LM393 module is an IR counter that has an IR transmitter and receiver. If any obstacle is placed between these sensors, a signal is sent to the microcontroller. The module can be used in association with a microcontroller for motor speed detection, pulse count, position limit, etc.

You can download the datasheet of this module here.

LM393 Sensor Pinout

This sensor has 3 pins:

  • VCC: Module power supply – 3-5.5 V
  • GND: Ground
  • OUT: Digital output data to the microcontroller

You can see pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
LM393 Infrared Speed Sensor Module × 1
Male Female Jumper Wire × 1

Software Apps

Arduino IDE

Interfacing LM393 Infrared Speed Sensor with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to LM393 sensor. Connect wires accordingly.

Step 2: Code

Install the following library on your Arduino.

https://github.com/brunocalou/Timer

Tip

If you need more help with installing a library on Arduino, read this tutorial: How to Install an Arduino Library

Upload the following code to your Arduino.
/*
  by MohammedDamirchi
  
Home
*/ #include "timer.h" Timer timer; const int LM393 = 2; int counter = 0; void setup() { attachInterrupt(digitalPinToInterrupt(LM393), count, RISING); Serial.begin(115200); timer.setInterval(1000); timer.setCallback(RPM); timer.start(); } void count() { counter++; } void RPM() { Serial.println(counter * 60); counter = 0; } void loop() { timer.update(); }
After running the code, you will see the following image in the serial output.
Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

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