Contactless Distance Measurement Tool

shape
shape
shape
shape
shape
shape
shape
shape
blog-details
October, 2021

Introduction:

In this blog, we will measure the distance from one place to another with the help of laser diode.

 

Requirements:

I) Arduino Nano & cable    

II) Ultrasonic Sensor         

III) Laser Diode                  

IV) OLED Display              

V) Resistor                           

VI) Jumper Wires               

VII) Sun-Board                    

 

Description:

Here we are going to make a device that can able to measure distance from one place to another or size of an object.

So basically, we are using one ultrasonic sensor that measures the size/distance by the help of Arduino and the laser diode is for marking purpose.

Whem we place the device in front of the object/wall it will show the distance in OLED display.

So lets start with the circuit diagram.

Circuit Diagram

                                                                                                   

 

 

 

 

 

 

 

Components

Pins

Arduino Pins

Ultrasonic

Sensor

TRIG

D7

ECHO

D8

OLED

Display

SCL

A5

SDA

A4

 

CODE:

//////////////////////////////////////////////////DEFINE PART
#include 
#include 
#include 
#include 
#define trigPin 7
#define echoPin 8

Adafruit_SSD1306 display(-1);

long duration;
int distance;

void setup() 
{
    ///////////////////////////////////////////DECLARATION PART
    pinMode(trigPin,OUTPUT);
    pinMode(echoPin,INPUT);
    Serial.begin(9600);
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display.clearDisplay();
}

//////////////////////////////////////////////////CONDITION PART
void loop() 
{
  digitalWrite(trigPin,LOW);
  delayMicroseconds(1);
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin,LOW);
  
  duration=pulseIn(echoPin,HIGH); //FORMULA FOR DISTANCE
  distance=(duration*0.034/2);
  
  Serial.print("Distance : ");
  Serial.print(distance);
  Serial.println(" cm ");
  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(1,1);
  display.print("Distance= ");
  display.print(distance);
  display.println("cm ");
  display.display();
  //delay(2000);
  display.clearDisplay();
}

 

 

 

For more details also go for the video.

Comments

Leave a Reply