7027

Ultrasonic Ranging Module, SN-HC-SR04

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

,

Related Post

WP_20150425_003

Comparison of HC-SR04, LV-MaxSonar-Ez(MB1010) and HRLV-MaxSonar-Ez(MB1013) Ultrasonic Sensors

cupboard

Build a Height Measurement Machine – Arduino

13 thoughts on “Ultrasonic Ranging Module, SN-HC-SR04

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

  2. 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)

  3. 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

  4. 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?

Leave a Reply

Your email address will not be published. Required fields are marked *