Ultrasonic Ranging Module, SN-HC-SR04

Recently Cytron is carrying another new ultrasonic sensor in stock which is called HC-SR04. Like others ultrasonic sensor, HC-SR04 uses sonar to determine distance to an object like bats or dolphins do. This sensor require an digital output (Trig) and input (Echo) pin to use it. We will show you the performance of this sensor by using Arduino. In order to make it easier, the HC-SR04 library in Arduino is also provided!

1.0 Introduction

Recently Cytron is carrying another new ultrasonic sensor which is called HC-SR04. Like other ultrasonic sensor, HC-SR04 uses sonar to determine distance to an object like bats or dolphins do. This sensor require a digital output (Trig) and input (Echo) pin to use it. We will show you the performance of this sensor by using Arduino. In order to make it easier, the HC-SR04 library in Arduino is also provided!

2.0 Requirement

2.1 Hardware

ARDUINO UNO

Screw Terminal Shield

LCD Keypad Shield

Ultrasonic Ranging Module                                                   

 

Jumper Wire Male to Female

      

2.2 Software

(i) Arduino IDE and Arduino Uno Driver – download from the Arduino download page

3.0 Methodologies

1. Prepare the hardware of the Arduino. Stack the Screw Terminal Shield and LCD Keypad Shield on the Arduino Uno.

2. Download the library and sample code of the ultrasonic sensor, SN-HC-SR04 under the attachment of this tutorial.

3. Open the sample code with Arduino IDE and upload it to the Arduino Uno. If you are a beginner to Arduino Uno, make sure you have already installed the driver on your computer. You can refer to the link below for getting started with the Arduino Uno.

4. After the sketch is uploaded, the LCD will display as below:

5. After making sure the Arduino is ready, it is time to interface with the ultrasonic sensor. Power off the arduino and connect the wire as shown below. Careful! Make sure the connection between Arduino and SN-HC-SR04 is correct. Wrong connection may spoil both hardware.

  • VCC <–> 5V
  • Trig <–> D12
  • Echo<–> D13
  • GND <–>GND

6. Power up the Arduino and now start testing the sensor by holding some object in front of the sensor. The LCD will show the distance between the sensor and the object in cm.

7. Done!

Attachment

SN-HC-SR04 with Arduino library and Demo

BUY

15 thoughts on “Ultrasonic Ranging Module, SN-HC-SR04”

  1. Can i dont connect this sensor to arduino uno…i connect it to my own main board which has pic f18…
    Can it function as normal?

  2. Hello, Could you help me install the library? I tryed and didint work.. I need rename the library with some diferente name? or can I paste with this name in download? any nice codes for good precision? thanks

  3. zaim, it powered up by arduino via pin +5v and GND (which is arduino is powered up by the usb cable connected to the arduino)

  4. hey, i was wondering…
    is this ultrasonic ranging sensor powered up by battery or the usb cable connected to the arduino????

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorail

Safe Box Using I2C LCD and 4×4 Keypad On Arduino.
Send Sensor’s Data to ThingSpeak Using Raspberry Pi
Getting Started with Raspberry Pi 4B-1GB Beginner Set
5 Major Upgrades on Raspberry Pi 4 Model B
Height Measurement Using Ultrasonic Sensor and Dot Matrix on Maker UNO
Scroll to Top