Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

Components and supplies

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
Arduino UNO
×1

About this project

Ultrasonic Range Detector With Arduino Using The SR04 Ultrasonic Sensor

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

This is a preliminary project that will take you through the steps I took to get the SR04 ULTRASONIC SENSOR connected and working to the Arduino.

Step 1: Parts List

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
  • Arduino Uno or compatable
  • SR04 Ultrasonic Sensor
  • Four male to female Jumper Wires

Let’s do it!.

Step 2: Connecting the SR04 Ultrasonic Sensor to the Arduino

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
  • VCC pin to the Arduino 5v
  • GND pin to the Arduino GND
  • TRG pin to the Arduino Digital pin 12
  • ECHO pin to the Arduino Digital pin 11

That's all the wiring you need..

Next step, load the Software library and sketches.

Step 3: Download SR04 Library and install to Arduino IDE

You need to download another Library to get the Arduino to talk with the SR04 sensor. The sensor I got didn't come with any documentation, so I Googled around until I found a library that works.

Download the library unzip it, and install it in the Arduino IDE. Place it inside your Arduino libraries folder , and restart the Arduino IDE. For convenience, I included the file in the files section below,

  • You should now be able to see the library and examples in select File > Examples > NewPing > NewPingexample sketch load the sketch to your Arduino.
  • If you were successful at installing the libraries, and loading the NewPingexample sketch, Compile the sketch by clicking on the verify button and make sure there are no errors.

It's time to connect your Arduino to your PC using the USB cable. Click on the upload button to upload the sketch to the Arduino.

Once uploaded to the Arduino, open the serial monitor, and you should see the distance data stream coming from the sensor,

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

Click here to download the library.

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

To get all the resources.

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor
Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

Thank you!

Code

  • NewPing.zip
NewPing.zipC/C++
No preview (download only).

Schematics

Build an Ultrasonic Range Detector Using Arduino UNO and SR04 Sensor

Manufacturing process

  1. Connecting an HC‑SR04 Ultrasonic Sensor to a Raspberry Pi – A Practical Guide
  2. K30 CO2 Sensor: Real‑Time Indoor Air Quality Monitoring
  3. FlickMote: Gesture‑Controlled IR Remote for Smart Home
  4. Build a Simple Obstacle Sensor with Arduino – Easy IR LED & Photodiode Tutorial
  5. Integrating a DFRobot Capacitive Fingerprint Sensor with Arduino or ESP8266
  6. Compact Arduino Radar System with HC‑SR04 Ultrasonic Sensor & 1.8" Display
  7. Arduino Ultrasonic Distance Sensor Project: HC‑SR04 Range Finder
  8. Build an IR Sensor Project with Arduino UNO – Simple Guide
  9. Android Motion‑Detection Camera Controlled by Arduino MCU
  10. Mastering the HC‑SR04 Ultrasonic Sensor with Arduino: A Complete Tutorial