The HC-SR04 ultra sonic distance sensor

SR04 - module

A great toy, sorry, I mean addition to the kit.

It seems the SR04 (“SR zero 4”) is very good at detecting within an angle of +/- 22.5 degrees

SR04 - angle

A ‘ping’ is a signal sent out, with the intention that something will ‘reflect’ it back, revealing the existence of that thing. The sensor sends out pulses (‘pings’) of ultra sonic pulses and can read the ‘reflected’ signals. You cannot hear it, but it’s actually a noise. The ‘ping’ is the same as an echo.

The whole ‘ping’ things was recently improved and is generally refereed to as “New Ping”.

Since we first looked at this just a couple of weeks ago, the SOURCE I mentioned has since moved here: (do read the whole page.

The Arduino needs instructions on how to understand / interact / handle the distance sensor. This is achieved by adding instructional files (programming code) into the library” where all other instructions that tell the Arduino hot to interface with all other hardware are kept. Example INSTRUCTIONS on how to install library files are found here:

and the ACTUAL “NEW PING” LIBRARY FILES are here (version 1.6 BETA):

The circuit diagram:

(Pin 12 of the Arduino goes to the ‘trigger’ pin of the SR04. Pin 11 (a PWM pin – significan??) of the Arduino goes to Echo. The power supply to the SR04 can come from the Arduino or an independent 5V supply. If you do use an independent power supply then remember you must connect the ‘grounds’ of the Arduino and the independent power supply. — It’s going to be easier to use the Arduino +5V output pin for niow.

Do look at the example sketches. There are a few good and come in a number of flavours – which can be more powerful / useful for certain applications 🙂 Sketches here:!examples

The support forum also gives help on how to use multiple sensors

My very big thanks to “teckel”


for all his hard work do that people like me can play happily with our toys.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s