Вы находитесь на странице: 1из 7

Ultrasonic Distance

Measurement

Team Members: RA1611020010132 Lakshyya Kothari


RA1611020010072 Amitabh Saxena
RA1611020010128 Sarang Kejriwal
RA1611020010052 Jojin J. Jolly
RA1611020010092 Akhilesh Chamoli
Abstract: To display the distance between an object and sensor on the LCD.
This concept can be used for sensing the nearby objects and the distance from
the source. For example, in autonomous cars, this concept would allow the car
to judge the safe distance and automatically decide if the distance is safe,
otherwise adjust the speed accordingly. Another use case could be for collision
avoidance, allowing any moving object to decide the distance from the obstacle
and hence avoid it. This allows the autonomous technology to move forwards
as whole, progressing towards the goal of a complete autonomous car.

Description: Using an Ultrasonic sensor, measure the distance between the


object and the sensor and print that value to the LCD. This is
done by dividing the input from the sensor by 29, as an
ultrasonic wave takes 29 microseconds to travel and then
dividing by 2 to allow for the wave to be transmitted and the
reflected. Hence the distance obtained is in centimetres. The
materials used are an Arduino Uno, Ultrasonic Sensor, LCD and
a 5V potentiometer.
Code:

/*
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/

// include the library code:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// declare the pins for signal and led


const int pingPin = 7;
const int ledPin = 13;

void setup() {

// start a serial interface for the ultrasonic sensor


Serial.begin(9600);
pinMode(ledPin, OUTPUT);

// set up the LCD's number of columns and rows:


lcd.begin(16, 2);

// Print the inital message to the LCD.


lcd.print("Distance : ");
}

void loop() {

long duration, cm;


// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);

// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);

// convert the time into a distance


cm = microsecondsToCentimeters(duration);

// set the cursor to column 0, line 1


// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);

// print the distance from the object


lcd.print(cm);
lcd.print(" cm");
delay(100);
}

long microsecondsToCentimeters(long microseconds) {


// The speed of sound is 340 m/s or 29 microseconds per centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
Screenshots:
Applications –
• Autonomous Cars
• Collision warning systems
• Controlling the level of liquid in a container
• Detecting presence of objects

Future Improvements –
• Improve the range of the sensor
• Improve the accuracy of the device
• Allow for detecting multiple objects simultaneously
• Daisy chain multiple sensors together

Conclusion: The Ultrasonic Distance Measurement project serves as a proof


of concept for demonstrating the applications of ultrasonic
distance measurement in the field of autonomous cars as well
as other fields.

Вам также может понравиться