Distance Measuring Device with Automatic Alarm

Distance Measuring Device with Automatic Alarm

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com

Today I am going to show you How to make a Distance Measuring Device with Automatic Alarm using an Arduino Uno Board and Ultrasonic sensor.It will show you distance in a LCD display and If Something will come in a fixed range it will warn you with message on LCD,LED light and sound.All the parts are attached on a breadboard with wires. 
Final Video-



Watch it in action here

Where we can use It/Applications:-

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com
it can be used …….

  1. As an Automatic Door bell-Just place it on the door and if some one will come in the range(2cm-450cm).it will inform You.
  2. As Digital Distance Measurement Tool– Measure distance in centimeter or inches.
  3. Anti-theft Alarm.
  4. Parking area -If any vehicle is too close to the wall or other vehicle then it will warn the driver with sound or warning message on lcd.
  5. In vehicle 

Requirements:-

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com


This is the list of parts needed to make the Distance Measuring Device with Automatic Alarm
.

  1. 1 x Arduino UNO board
  2. 1 x HC-05 Ultrosonic sensor
  3. 1 x LCD Display (16A1,16A2 or any other)
  4. 1 x Breadboard
  5. 1 x 10k Potentiometer/variable resistors(You can also use 5k or 50k)
  6. Buzzer
  7. LED bulb
  8. Some male to male jumper wires.
  9. Power Bank or Battery
  • Arduino IDE installed in pc with some basic information about how to use it.

Basic Information About Parts and links to Buy –

  • Arduino UNO board

How To Make a Thermometer using Arduino and LM35

The Arduino Uno is a microcontroller board based on the ATmega328. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs ,a 16 MHz ceramic resonator ,a USB connection ,a power jack ,an ICSP header and a reset button. 


It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. 
Microcontroller ATmega328 Operating Voltage 5V Input Voltage (recommended) 7-12V Input Voltage (limits) 6-20V 
Digital I/O Pins 14 (of which 6 provide PWM output) 
Analog Input Pins 6 
DC Current per I/O Pin 40 mA 
DC Current for 3.3V Pin 50 mA 
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader 
SRAM 2 KB (ATmega328) 
EEPROM 1 KB (ATmega328) 
Clock Speed 16 MHz

Buy Now from here-

Arduino Uno R3 ATmega328P ATMEGA16U2 Compatible with USB Cable

HC-SR04 Ultrasonic Sensor

HC-SR04 Ultrasonic Module Distance Measuring Transducer Sensor DC 5V

  • The HC-SR04 ultrasonic sensor uses sonar to measure distance to an object. It offers excellent range accuracy and stable readings in an easy-to-use package. It operation is not affected by sunlight or black material like Sharp rangefinders are (soft materials like cloth can be difficult to detect). Module main technical parameters: 
  • 1.Working Voltage : 5V(DC) 
  • 2.Static current: Less than 2mA. 
  • 3.Output signal: Electric frequency signal, high level 5V, low level 0V. 
  • 4.Sensor angle: Not more than 15 degrees. 
  • 5.Detection distance: 2cm-450cm. 
  • 6.High precision: Up to 0.3cm 
  • 7.Input trigger signal: 10us TTL impulse 
  • 8.Echo signal : output TTL PWL signal Mode of connection: 1.VCC 2.trig(T) 3.echo(R) 4.GND The basic operation principle is below : use IO port TRIG to trigger ranging. It needs 10 us high level signal at least Module will send eight 40kHz square wave automatically, and will test if there is any signal returned. If there is signal returned, output will be high level signal via IO port ECHO. The duration of the high level signal is the time from transmitter to receiving with the ultrasonic. Testing distance = duration of high level*sound velocity(340m/s) / 2 You can use the above calculation to find the distance between the obstacle and the ultrasonic module.
  • NOTE : The module has a blind spot of 2cm(very near). So obstacle held too closely will not be detected.

 

LCD(16A1,16A2 or any other)

5V DC 16 x 2 Lines ASCII Character LCD Display With Yellow Backlight Product Description: o LCD display module with Yellow Backlight o SIZE : 20×4 (2 Rows and 16 Characters Per Row) o Can display 2-lines X 16-characters o Operate with 5V DC o Wide viewing angle and high contrast o Built-in industry standard HD44780 equivalent LCD controller o Commonly Used in: Student Project, Collage,copiers, fax machines, laser printers, industrial test equipment, networking equipment such as routers and storage devices o LCM type: Characters ABOUT This is a basic 16 character by 2 line display Yellow Back light . Utilizes the extremely common HD44780 parallel interface chipset (datasheet). Interface code is freely available. You will need 7 general I/O pins(If use in 4-bit Mode) to interface to this LCD screen. Includes LED backlight. 

LCD 16×2 Alphanumeric Display(JHD162A) for 8051,AVR,Arduino,PIC,ARM All

Above Three are main component and Buy Breadboard,Buzzer and LED buld from local shop they will be costly on the online shops.

Circuit Diagram:-

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com
Follow The above circuit and Assemble everything on the breadboard carefully and Attach the Arduino board with PC with connecting cable and Upload the following code.

Programming:-

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com

//Distance measuring Tool with Automatic Alarm.#By Sourabh Kumar @ www.androroot.com
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Pin diclaration for LCD
int pingPin = 7;  //Pin diclaration for Trig of Ultrasonic sensor
int inPin = 8;   //Pin diclaration for ECHO of Ultrasonic sensor
const int buzzer=9; //Pin diclaration for buzzer and led
long duration, inches, cm;
int indec, cmdec;
int inchconv = 147;
int cmconv = 59;
String s1, s2;
void setup() {
  lcd.begin(8, 2);  //LCD Type change it according to yours lcd
  pinMode(pingPin, OUTPUT);
  pinMode(inPin, INPUT);
  pinMode(buzzer, OUTPUT);
}
void loop()
{
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(pingPin, LOW);
  duration = pulseIn(inPin, HIGH);
  inches = microsecondsToInches(duration);
  indec = (duration – inches * inchconv) * 10 / inchconv;
  cm = microsecondsToCentimeters(duration);
  cmdec = (duration – cm * cmconv) * 10 / cmconv;
  s1 = String(inches) + “.” + String(indec) + “in” + ”     “;
  s2 = String(cm) + “.” + String(cmdec) + “cm” + ”     “;
  lcd.setCursor(0, 0);
  lcd.print(s1);
  lcd.setCursor(0,1);
  lcd.print(s2);

  delay(600);
  if(cm<=15)  //If some obstacle comes in this range(Mine=15cm)Buzzer starts.Change it according to your purpose.
  {
    digitalWrite(buzzer, HIGH);
    delay(100);
    digitalWrite(buzzer, LOW);
    delay(10);
     lcd.setCursor(0,0);
    lcd.print(“Andro Ro”);
    lcd.setCursor(0,1);
    lcd.print(“ot-Alarm”);
    delay(800);
  }
}
long microsecondsToInches(long microseconds)
{
  return microseconds / inchconv;
}
long microsecondsToCentimeters(long microseconds)
{
  return microseconds / cmconv;
}

————————————————————————–

  • Above is the basic code
  1. Note- i am using an old 16×1 lcd which only works correctly when it will be assumed and declared as 8×2 lcd.But when you will use 16×2 display then this problem will not accrue for 16×2 display just find   lcd.begin(8, 2);  //LCD Type change it according to yours lcd in the code and replace (8,2) according to your display as (column,row) .let you have a 16×2 display then replace (8,2) with (16,2).and if you have 20×4 display just replace the (8,2) with (20,4).
  2. Note- I fixed the distance to warn me as 15cm if(cm<=15)  //If some obstacle comes in this range(Mine=15cm)Buzzer starts.Change it according to your purpose.So when some obstacle will come in the range it will inform me through the alarm .And You can change it According to your purpose and need but in between (2cm-250cm).In this range it works very great. 

Download theProgram file- “Distance measuing tool and alarm.ino” from Here

Now You have code so just Upload it on The Arduino Board.Check The circuit and connect a 9V battery  to the arduino board and enjoy.

Final result:-

How to make a Distance Measuring Device with Automatic Alarm-Androoot.com



How to make a Distance Measuring Device with Automatic Alarm-Androoot.com
How to make a Distance Measuring Device with Automatic Alarm-Androoot.com

So I hope Our this post will definitely help you to make a Distance Measuring device with automatic alarm using Arduino Board and HC-SR04 ultrasonic sensor.And this device can be used in many Application and in many place with some basic modification.

Also Read-

How to make an Obstacle Avoiding robot using arduino & L293d IC- – Link Updated


Keep Visiting and sharing.

About Sourabh Kumar

Sourabh Kumar is a Tech savvy B.Tech(ECE) student living in Jaipur, India. He is a Blogger and fan of photography, technology, Robotics, and design. He is also interested in programming and innovation. He loves technology, gadgets and Spends lots of time with them.

View all posts by Sourabh Kumar →

2 Comments on “Distance Measuring Device with Automatic Alarm”

Leave a Reply

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