Click here for a free subscription to "HDE" our site newsletter.

Arduino Programming the HC-SR04 Project Circuit Diagram

Circuit diagram for the Arduino HC-SR04 programming project

If you want to be able to examine the waveforms produced by this and other projects then get a copy of my book: Sound Card Oscilloscope and build yourself some very capable test gear.

Arduino HC-SR04 circuit diagram
Distance finder circuit diagram

See the full range of Arduino products

You just need 4 jumper wires to connect this up. I used an old piece of ribbon cable that I had lying around. I stripped off the ends, soldered half an inch of solid wire on the end then covered the joint with some sleeving. It works well but it can be very tedious making the cables. By the time I had finished I told myself that I wasn't going to do that again and ordered up some ready made jumper cables to use next time.

I used 4 solid wires to bridge the center gap in the breadboard and that's all you need to do. On the next page you can download the software that you need.



Now subscribe to our newsletter and don't miss a thing
 



Comments (13)

Topic: Arduino Programming the HC-SR04 with Interrupts
Full StarFull StarFull StarFull StarHalf Star 4.5/5 (9)
Facebookdel.icio.usStumbleUponDiggGoogle+Twitter
Full StarFull StarFull StarFull StarFull Star
Kim (South Korea) says...
amazing post of interrupt and operating ultrasonic module. great help for my advanced project! thx a lot Smile
11th August 2022 4:31pm
Full StarFull StarFull StarFull StarEmpty Star
Biomedical engineering project (India) says...
nice information
3rd March 2021 6:54am
Full StarFull StarFull StarFull StarFull Star
Fabri (Italy) says...
Hi, i'm testing you code on arduino mega,
is it possible that the only working pin for Echo signal is 2?
Why can't I put it on a random digital input, since the interrupt is generated by the timer?
20th April 2020 12:42pm
Full StarFull StarFull StarEmpty StarEmpty Star
Juan Alberto Guerrero Ramírez (Spain) says...
I´m quite new in Arduino and I´m trying to understanding interrupts and etc...

I guess this code is super, however, it is a bit difficult for me to understand.

In any case, many thanks for sharing and useful info.

Best Regards,
Juan Alberto
4th January 2020 1:02pm
ElysiumPro (India) says...
Excellent information about working HC-SR04. Thanks you so much for sharing the valuable information.
28th January 2019 11:31am
Full StarFull StarFull StarFull StarEmpty Star
embeddedschool (India) says...
Informative content about arduino programming.simple and Easy to understand embedded beginners. Thanks for sharing this kind of post
4th August 2018 10:23am
Mahdi (Iran) says...
hi
for my lesson i need your code .
can you send it for me please.
i observe publisher's rights, and introduce your site to my friends.
23rd June 2018 6:55am
Full StarFull StarFull StarFull StarFull Star
Mohamed says...
hello

i want to use input capture in the timer so i can see in your code that you are using timer and intrrupt , however is this intrrupt is ( the intrrupt for the timer ) or normal intrrupt , im asking about that cuz my all intrrupt pins is totaly busy and i want to use the input capture feature in the arduino mega ...??
11th May 2017 12:56pm
Full StarFull StarFull StarFull StarFull Star
Reema Shrestha (Nepal) says...
I've been trying to use Interrupt and timer for two ultrasonic sensors to measure time interval between when the first sensor's echo pin is HIGH to second sensor's echo pin is HIGH. So could help me with it?
16th February 2017 5:31pm
Forest Cooper (US) says...
I don't know those circuit details.
16th February 2017 5:56pm
Reema Shrestha (Nepal) says...
If you could,just help me with the algorithm.The circuit is similar to the one used above but I've used two sensors. When the moving object is detected by the first sensor then the interrupt should be called and timer should record the time until the object is detected by the second sensor. What I've been stuck to is,mode of Interrupts(). According to your code the timer measures the value from one state of the pin to the change of pin. But in mine the case should be HIGH for both. I mean when ... Read More
17th February 2017 11:09am
Full StarFull StarFull StarFull StarEmpty Star
Bob Jones (US) says...
Steve, I have been reading as much as I can find about how to program the HC-SR04 Ultrasonic Sensor using a timer interrupt. I got your sketch working and am adapting it, but hitting a question about delays. In your code, you use a for loop to simulate a delay. Your comment says that a delay won't work. So what I have done is use the micros() function to do the same. Only problem is that it doesn't work... yet. Would you be willing to take a quick look at my code and help me make it ... Read More
20th December 2015 4:52am
Full StarFull StarFull StarFull StarFull Star
Forest Cooper (US) says...
Hello, I am looking for 35 of the HC-RS04 modules and cards. Do you know where I can purchase these in the US? I need them in 1-2 days! Thanks for your help.
21st May 2014 4:36pm

Add Comment

* Required information
(will not be published)
 
Bold Italic Underline Strike Superscript Subscript Code PHP Code Quote Insert line Bullet list Numeric list Link Email Image Video
 
Smile Sad Huh Laugh Mad Tongue Crying Grin Wink Scared Cool Sleep Blush Unsure Shocked
Captcha
Refresh
 
Enter code:
 
Notify me of new comments via email.
 
Remember my form details on this computer.
 
I have read and understand the privacy policy. *
 
I have read and agree to the terms and conditions. *
 
Click here for a free subscription to "HDE" our site newsletter.