Proximity Alarm Distance Meter

Proximity Alarm Distance Meter © GPL3+

This project can perform a number of tasks simultaneously while being monitored through serial port on your computer or on your mobile.

  • 4,071 views
  • 2 comments
  • 22 respects

Components and supplies

Apps and online services

Ide web
Arduino IDE
arduino bluetooth controller apk
U can find it on playstore
microsoft visio professional

About this project

Introduction

As earlier stated, this project can perform a number of tasks like proximity alarm ranging from 2cm to 400cm (i.e minimum and max range of the ultrasonic sensor) depending on the distance you input in your Arduino sketch. It can also be used for electronic measurement of distances ranging from 2cm to 400cm(4m).

You can also see the distance reading in meters, cm, and inches in your serial monitor.

The reason for the Bluetooth module is to see your serial readings mobile via Bluetooth through the Android application I mentioned earlier Arduino Bluetooth controller.

Launch the Android application:

Distance reading starts immediately after successful connection.

Few minutes clip

Code

ultrasonic_sensor___buzzer.inoArduino
// proximity sensor
// Tgst hassan shettima lawan contact me on;
// hassanshettima705@gmail.com +2347062769748 +2348183555452



const int buzzerPin = 8;               // buzzzer signal pin attached to digital pin 8
const int trigPin = 11;               // ultrasonic triggerPin connected to digital pin 11
const int echoPin = 10;               // ultrasonic echoPin connected to digital pin 10
int ledPin = 13;                      // LED positive connecteed to digital pin 13 (no need for resistor)
long duration;
float distanceMeters, distanceCm, distanceInch;

void setup() {                        // define all digital and analog pins
  pinMode(13, OUTPUT);                // LED pin as output
  pinMode(trigPin, OUTPUT);           // trigger pin as output because it sends signal
  pinMode(8, OUTPUT);                 // buzzer pin as output
  pinMode(echoPin, INPUT);             // echo pin as input becaue it recievs signals
  Serial.begin(9600);                  // initiate serial communication
}

void loop() {
  digitalWrite(trigPin, HIGH);                // initiate the ultrasonic sensor for sending and receiving
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  duration = pulseIn(echoPin, HIGH);

  distanceMeters = duration * 0.00034 / 2;      // speed of sound per second; divide by 2 due to then sound coming back to the echo part of the sensor
  distanceCm = duration * 0.034 / 2;
  distanceInch = duration * 0.0133 / 2;

  Serial.print("Distance: ");                     // print distance (meters) in serial monitor
  Serial.print(distanceMeters);
  Serial.println("  Meters");
  delay(300);

  Serial.print("Distance: ");                      // print distance (centi meters) in serial monitor
  Serial.print(distanceCm);
  Serial.println("  cm");
  delay(300);

  Serial.print("Distance: ");                        // print distance (inches) in serial monitor
  Serial.print(distanceInch);
  Serial.println("  inch");
  delay(300);
  Serial.println("----------------------------");     // seoeration


  if (distanceCm <= 30 )    {                           // if distance is greater than or equal to 30 cm on LED and on buzzer ON and OFF
    digitalWrite(13, HIGH);                                 // ...... with delay as interval
    tone(buzzerPin, 1200);
    delay(500);                                                 //   u can tweak the code to suit yourn needs
    noTone(buzzerPin);
    digitalWrite(13, LOW);
    delay(5);
  }
  else if (distanceCm > 100 )    {
    digitalWrite(13, LOW);
    noTone(buzzerPin);
  }
}

Schematics

proximity_alarm_distance_sensor_1SkASpI1Lh.pdf

Comments

Similar projects you might like

DIY Distance Meter with Arduino and a Nokia 5110 Display

Project tutorial by Nick Koumaris

  • 6,377 views
  • 0 comments
  • 16 respects

Distance Sensor and OLED

Project tutorial by javier muñoz sáez

  • 22,054 views
  • 22 comments
  • 65 respects

Distance Alarm System

Project tutorial by Darwin Dela Cruz

  • 2,973 views
  • 3 comments
  • 14 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 37,888 views
  • 5 comments
  • 21 respects

A Very Compact Alarm with Card Reader and Real-Time Clock

Project tutorial by Simone Adobs

  • 5,970 views
  • 3 comments
  • 30 respects

DIY Portable Distance Detection Device

Project tutorial by Viktor S

  • 6,433 views
  • 5 comments
  • 18 respects
Add projectSign up / Login