Introduction: Project 7 : Ultrasonic Model HC-SR04

About: I like Arduino. I learn new things about it every day and also upload it here on Instructables.

Ever wanted to know the empty distance between any two points. Use the Ultrasonic HC-SR04 with the Arduino Board. So let's get started !!!

Step 1: Step 1: What You Require?

  1. Arduino Uno or Arduino Mega 2560 (They are the beginning boards of Arduino)
  2. Jumper Wires (Male to Male)
  3. Breadboard
  4. HC SR04
  5. Cable (To connect board with your Computer for uploading the Program)
  6. Arduino IDE Program (Downloadable fromhttps://www.arduino.cc/en/Main/Software

Step 2: Step 2: Build Your Circuit and Know Why Is It Designed So?

GND on the Ultrasonic Module is to be powered by negative energy. You can use external power source also but I have used GND power from the Arduino Board itself.

Trig and Echo need to be connected to Analog Input Pins. An analog input converts a voltage level into a digital value that can be stored and processed in a computer.

VCC on the Ultrasonic Module is to be powered by positive energy. You can use external power source also but I have used 5V power from the Arduino Board itself.

Step 3: Step 3: Now for the Software

#include <NewPing.h>

#define TRIGGER_PIN 12

#define ECHO_PIN 11

#define MAX_DISTANCE 200

NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);

void setup()

{ Serial.begin(115200); }

void loop()

{ delay(50);

Serial.print("Ping: ");

Serial.print(sonar.ping_cm());

Serial.println("cm"); }

-------------------------------------------

You will need the NewPing Library, you can Download it Here : https://bitbucket.org/teckel12/arduino-new-ping/downloads/