Coder Social home page Coder Social logo

21005984 / experiment--04-interfacing-digital-output-with-arduino-ultrasonic-sensor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vasanthkumarch/experiment--04-interfacing-digital-output-with-arduino-ultrasonic-sensor

0.0 0.0 0.0 257 KB

License: BSD 3-Clause "New" or "Revised" License

C++ 100.00%

experiment--04-interfacing-digital-output-with-arduino-ultrasonic-sensor's Introduction

EXPERIMENT-NO--04-Distance measurement using Ultrasonic sensor

AIM:

To measure the distance of the given obstacle using ultrasonic sensor(HC - SR04).

COMPONENTS REQUIRED:

  1. ultrasonic sensor module HC-SR04
  2. 1 KΩ resistor
  3. Arduino Uno
  4. USB Interfacing cable
  5. Connecting wires

THEORY:

The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet.

The operation is not affected by sunlight or black material, although acoustically, soft materials like cloth can be difficult to detect. It comes complete with ultrasonic transmitter and receiver module. Technical Specifications Power Supply − +5V DC Quiescent Current − <2mA Working Current − 15mA Effectual Angle − <15° Ranging Distance − 2cm – 400 cm/1″ – 13ft Resolution − 0.3 cm Measuring Angle − 30 degree

The ultrasonic sensor uses sonar to determine the distance to an object. Here’s what happens:

The ultrasound transmitter (trig pin) emits a high-frequency sound (40 kHz). The sound travels through the air. If it finds an object, it bounces back to the module. The ultrasound receiver (echo pin) receives the reflected sound (echo). The time between the transmission and reception of the signal allows us to calculate the distance to an object. This is possible because we know the sound’s velocity in the air. Here’s the formula:

distance to an object = ((speed of sound in the air)*time)/2 speed of sound in the air at 20ºC (68ºF) = 343m/s

FIGURE 01 CIRCUIT OF INTERFACING ULTRASONIC SENSOR

image

PROCEDURE:

  1. Connect the circuit as per the circuit diagram
  2. Connect the board to your computer via the USB cable.
  3. If needed, install the drivers.
  4. Launch the Arduino IDE.
  5. Select the board (If you the board is arduino uno, select accordingly).
  6. Select your serial port, accordingly ( E.g. COM5 )
  7. Open the file of the program and verify the error , clear if any errors that are existing
  8. Upload the program and check for the physical working.
  9. Ensure safety before powering up the device
  10. Plot the graph for the output voltage vs the resistance

PROGRAM

#define echoPin 9
#define trigPin 10

long duration;
int distance;
void setup()
{
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600);
}
void loop()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration *0.034/2;
  Serial.print("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
}

OUTPUT

My image

RESULTS

Thus the distance value is measured in"CM" using ultrasonic sensor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.