A Sensitive DIY Ultrasonic Range Sensor

I needed some ultrasonic range finders for my project. But most of the commercial sensors like Parallax’s PING sensor and other similar products are quite expensive, especially if multiple units are needed. So I thought why not building it myself?

The theory behind ultrasonic ranging is quite simple. Typically a short ultrasonic burst is transmitted from the transmitter. When there is an object in the path of the ultrasonic pulse, some portion of the transmitted ultrasonic wave is reflected and the ultrasonic receiver can detect such echo. By measuring the elapsed time between the sending and the receiving of the signal along with the knowledge of the speed of sound in the medium, the distance between the receiver and the object can be calculated. The picture below (source: Wikipedia) illustrates this basic principal:

Ultrasonic Ranging (Courtesy of Wikipedia)

Ultrasonic Ranging (Courtesy of Wikipedia)

In my design, I used separate transducers for transmitter and receiver. It is possible to multiplex the transmission and receiving with a single transducer (e.g. Maxbotix range finders), but the design would be significantly more complex.

Ultrasonic Transducer

There are quite a few ultrasonic transducers to choose from, and the main criteria are the resonant frequency, radiation pattern and sensitivity. Generally speaking, these parameters affect the measurement in the following ways: a higher resonant frequency can provide finer details of the surroundings due to the shorter wavelength. A more directional radiation pattern can also enhance the resolution of the measurement. Sensitivity affects the efficiency of the transducer and also attributes to the SNR (signal to noise ratio).

I bought these 24 kHz transducers on sale (see picture below). These transducers are very inexpensive (around a dollar each, and even cheaper when on sale) but effective. With properly designed circuits these sensors can easily achieve a range of more than 20 feet. Of course, using the higher priced 40 kHz sensors should achieve even better performance.

24 kHz Ultrasonic Transducers

24 kHz Ultrasonic Transducers

But for these DIY ultrasonic range finders, the choice of the transducers are really not that critical and this transducer really hits the performance to price sweet spot.

The Transmitter

The ultrasonic transmitter is powered from ATmega328’s counter 1 PWM output (chip pin 16 and Arduino digital pin 10). In order to achieve the maximum output power of the transducer for a given supply voltage, I used the bridged output design as shown in the following schematics:

Ultrasonic Transmitter

Ultrasonic Transmitter

This bridged circuit produces an output voltage roughly twice the Vcc. I used +5V for Vcc and the result is already quite good (more than 20 feet of range). For even longer range measurement, you can safely increase this driving voltage to around 12 Volts as most ultrasonic transducers can be driven with voltage as high as 20 to 30 volts. If you increase the voltage significantly above 5V however, you will have to change the transistors to allow more power dissipation. With 2N3904 and 2N3906 the transistors get warm during normal operation and would heat up drastically with voltage above 6V.

Here is the output of the ultrasonic burst measured at the output transducer’s terminals:

Output Waveform

Output Waveform

The small “ladders” at the half-way voltage point in the output waveform is due to the slight added delay of the inverted signal stage due to the use of an extra NPN transistor. To obtain purer rectangular wave form and reduce switching loss, a PNP transistor with similar timing parameters can be used on the side that is directly connected to the driving signal. For this application though, the waveform is more than adequate and the added switching loss is negligible.

The transmitter and receiver transducers can be mounted on a circuit board with approximately one inch of spacing (see below).

Ultrasonic Range Sensor

Ultrasonic Range Sensor

In order to reduce possible interference from the reflected ultrasonic waves, the components are mounted on the reverse side of the board (below is the H-bridge circuit that drives the ultrasonic transducer, a few decoupling capacitors are used to reduce noise and they are not shown in the schematics above):

H Bridge

H Bridge

The code to drive the transducer is similar to that I used previously, except that I changed the pre-scalar to 1 so that the output frequency can be controlled more precisely in the kHz range.

void startTransducer(float freq, float dutyCycle)
{
  if (dutyCycle > 0.5) dutyCycle = 0.5;
  else if (dutyCycle < 0) dutyCycle = 0;

  cli();
  TCCR1B = _BV(WGM13) | _BV(CS10) | _BV(ICNC1);
  //f0 = fclk / (2 * N * Top)
  long topv = (long) ((float) F_CPU /(freq * 2.0 * 1.0));
  ICR1 = topv;

  OCR1A = (int) ((float) topv * dutyCycle);
  OCR1B = (int) ((float) topv * (1 - dutyCycle)); 
  DDRB |= _BV(PORTB1) | _BV(PORTB2);
  TCCR1A = _BV(COM1A1) | _BV(COM1B1); 
  sei();   
}

void stopTransducer()
{
  cli();
  TCCR1B = 0;
  sei();
  digitalWrite(9,LOW);
  digitalWrite(10,LOW);
}

The Receiver

The performance of the range sensor is largely determined by the sensitivity of the receiver for a given transmitter power level. Because the received signal is usually very weak (less than 1 mV), a high gain low noise amplifier is needed to ensure optimal performance.

I used a two stage inverted band-pass amplifier design (see below). Each stage has a gain of around 67 (36.5 dB) and the circuit has a combined voltage gain of 73 dB. The operational amplifier I used is National’s LPC662. In general, any operational amplifier with a sufficient gain bandwidth product should work just as well.

Each stage has a band-pass filter that is centered around the operation frequency (24 kHz). Because the amplifier has a very high gain, we must pay special attention to the circuit layout in order to prevent parasitic oscillation. The connection between the receiver transducer and the circuit input (6.8n capacitor) needs to be shielded to reduce noise and unwanted coupling.

Ultrasonic Receiver

Ultrasonic Receiver

Because we are using a single power supply the output voltage of the opamp is centered at around Vcc/2 (2.5V). In order to make it easier to process the echo, a diode (IN4148), capacitor (0.1uF) and resistor (10k) are used to demodulate the signal and a coupling capacitor (1uF) is used to rid the demodulated signal of the DC component.

You can see the demodulated envelope waveform from the following oscilloscope screenshots (you can ignore the frequency measurement as these signals are none-periodical the frequency readings are meaningless). The higher amplitude waveforms in both images are the results of the ultrasonic burst, the lower amplitude waveforms are from the echo. In the first screenshot on the left, two echoes can be seen.

Echo and the demodulated waveform 1

Echo and the demodulated waveform 1

Echo and the demodulated waveform 2

Echo and the demodulated waveform 2

The following screenshot shows the relationship between the ultrasonic pulses (measured from ATmega328 pin 16) from the transmitter and the demodulated echo output. One key observation is that the received signal takes much longer time to fade then the original pulse duration and thus we must add in some delay after the transmission of the ultrasonic pulses. A delay of 1 to 2 millisecond is typical. With a 1 millisecond delay, the shortest measurable distance is around 30 centimeters or one foot.

Demodulated Echo

Demodulated Echo

And here is a picture of the finished project.

Ultrasonic Range Finder

Ultrasonic Range Finder

Range Calculation

Since the measured distance is a function of the time interval between the time at which the pulse is transmitted and the time at which the echo is received, we need to reliability detect the echo.

Empirically, we can measure the peak of the received echo and use the time displacement to calculate the distance. We assume that the strongest echo comes from the closest object (this may not always be true as the reflectivity of different objects are different, but generally achieves very good results in real-world situations) and thus the peak measurement corresponds to the closest object’s position.

The code snippet below assumes that we are interested in measuring objects with a range of up to about 20 feet. After the pulses are transmitted from the transmitter, we wait for a millisecond for the initial receiver signal to fade. Then we search the peak value in the next 20 milliseconds or so (the loop limit 256 is set empirically, in the code below this setting corresponds to a 20 milliseconds interval between transmitted pulses which is suitable for distance measurement up to approximately 20 feet. To measure longer distance, the upper limit for the loop needs to be increased correspondingly) and assume that the peak comes from the first echo.

byte a = 0;
unsigned long t_start = 0;
unsigned long t_peak = 0;
unsigned long t = 0;
byte v_peak = 0;
const float SPEED_OF_SOUND_20C = 0.0003432; //meters per micro-second
float d = 0;

void loop()
{  
  startTransducer(24000.0, 0.5);
  delayMicroseconds(300);
  stopTransducer();

  v_peak = 0;
  t_start =micros();
  t_peak = t_start;
  delayMilliseconds(1);

  for (int i = 0; i < 256; i++) {
    a = analogRead(0);
    t = micros();

    if (a > v_peak) {
      t_peak = t;
      v_peak = a;
    }
  }

  t = t_peak - t_start;
  d = (float) t * SPEED_OF_SOUND_20C / 2.0;
  Serial.println(d , 2);
}

Here’s the full code listing for this project:
UltraSonicRangeFinder.tar.gz

The bill of material for this ultrasonic range finder is less than 5 dollars (excluding the MCU since it can be incorporated into your projects).

Update

I would like to thank Thomas for pointing out the mistakes in my H-Bridge schematic. The PNP transistor’s collector and emitter are swapped by mistake (I should have double checked the schematics. Anyway, the photo shows the correct orientation) and I have updated the image.

Also on the receiver side, the first OP’s output was missing connection to the 0.1uF capacitor, I have updated it as well.

Be Sociable, Share!

265 Comments

  1. […] A popular way to do this is to use ultrasound.  Kerry is sharing his experience of building his DIY Ultrasonic Range Sensor so that the rest of us can learn from what he built. Parallax has a product called PING which is a […]

  2. Dino says:

    Nice post! I have been wanting to design an ultrasonic range sensor from first principles for a while now. I’m interested to know more about design process. Why the choice of such a bridge for the transmitter and the filter circuit around the receiver? Did you review any app notes or other literature?

    • kwong says:

      1. Using a bridged amplifier doubles the driving voltage and thus increases the output power.
      2. Because the ultrasonic signal I am using is centered around 24 kHz, using filters around that frequency ensures that only the signal of interest gets amplified and thus reduces noises.

      Hope it helps.

  3. Rather ws sign in depth info. I am really glad to read this short article. Thanks for giving people nice articles.

  4. Andrew says:

    You may be able to get that 1ms delay down (i.e. measure closer objects) if you add some dampening resistance across the transducer. A tuned circuit would work better than a resistor but more of the energy intended to go to the transducer would go to the dampening circuit as well, and you may have to worry about creating a tank circuit and causing oscillation.

  5. hpux735 says:

    Awesome! I think I just bought those exact same transducers!! All electronics? Thanks for paving the way!

  6. penguMC says:

    Perfect! I’m going to make bunch of these, add an I2C interface and use them on my quadrapod:
    http://www.youtube.com/watch?v=6zRa06Jscac

  7. aggaz says:

    Amazing! Thank you for sharing!

  8. GR0B says:

    Amazing! Thanks for sharing, I might have to try and build this now.

  9. simon says:

    Thanks for sharing.

  10. […] Sensitive DIY Ultrasonic Range Sensor – [Link] Tags: range, receiver, transmitter, ultrasonic Filed in Sensor | 1 views No Comments […]

  11. Tius says:

    Amazing! Thank you for sharing!
    Can we transform the code into Arduino library?

  12. Thomas says:

    Please check the ‘H’ Bridge Schematic.

    The 2N3906 Transistors are incorrectly oriented. The Emitter and Collectors need to be swapped.

    Sincerely yours,

  13. Malikaii says:

    In the schematic for the receiver, why does the signal from the transducer not get shorted directly to ground? It seems like the path of least resistance leads directly to ground on the bottom side of the transducer.

  14. BobL says:

    The receiver jpeg appears to have a connection missing. The pin 1 of the left opamp is not connected.

    Why did you choose the 6.8nf cap in the receiver?

    • kwong says:

      Yes Bob, I noticed the missing pin yesterday and had corrected the drawing. The 6.8nF cap along with the 1.2K resistor form a first order high pass filter which has a cutoff frequency of 19.5 kHz.

      It doesn’t have to be precise but you should recalculate if you are using a different value to ensure that the cutoff frequency is outside of the operating frequency.

  15. psuedonymous says:

    Does the ATmega328 have enough power to perform a correlation of the output signal vs. the input? You could ‘chirp’ the output rather than ‘click’ it to improve the response: better range resolution, range discrimination (objects close together), noise discrimination, and potentially detection of velocity via frequency shift. See http://en.wikipedia.org/wiki/Pulse_compression?useskin=monobook

    • kwong says:

      Good suggestion. I believe ATmega328 certainly has the processing power to do autocorrelation. I will have to try this out. Stay tuned.

      • Don’t think that would work. For multiple reasons.

        The transducers don’t have enough of a bandwidth (they’re usually extremely narrow banded). The timings can get extremely tricky. Finally, for anything except the simplest matched filter (just a correlation between the echo and the time-inverse of the chirp) you’d need some hefty FFT processing and convolution. Which, i think (but might be wrong), is outside the capabilities of a humble (but versatile) AVR.

        How about a CPLD/FPGA + MCU combo?

  16. John says:

    Note that the bridge gets shortcircuited each time you change state. Eg. During the transition from 0 to 1 or 1 to 0, both left transistors conduct simultaneously. I woul really suggest exciting the top and bottom transistors separately with 2 pins
    of the microprocessor.

  17. maurizio says:

    Great work, congrats. I really love the care you put in explaining everything.
    I appreciated in particular the nice tx circuit. Why not save one transistor (and resistor) by exchanging the 2 transistors on le left side? I did not actually try this, but successfully built a simulation with Yenka

  18. edward says:

    Nice post.

    I am interested in making such a sensor to detect the distance of the sensor to a water level. However, I have to place the sensor very close to the waterlevel. The range is 1” to 5”.

    You have shown in the picture “Demodulated echo” that the receiver picks up a signal when the transmitter transmits, and that is why you add 1ms of delay. This of course is killing if you want to measure 1” distance. Could you tell me what the reason is that the receiver gets this signal? Is it because receiver and transmitter are mounted on the same PCB and thus pick up vibration through the PCB? Is so, do you think that putting the receiver and transmitter on different brackets would help?

  19. Tius says:

    Can I substitute the LPC662 with the LM358? Thanks.

  20. Matt says:

    Awesome article! Just one small design consideration: the H Bridge is not actually doubling the voltage, but inverting the voltage across the transceiver very quickly, making 10 v pk-pk. While this does boost the range of the transceiver, it will also mean a constant current draw, even while not transmitting. In low power/battery operated circuits, adding some kind of toggle while not transmitting would improve battery life/power efficiency.

  21. Question says:

    Where did you purchase the transducers?

  22. BarberRouge says:

    Hi
    I’m pretty new to this .. so here comes the my question. I do not understand that at the schematics it refers to Arduino digipin 10 analog and analog pin0 and the code reads the Arduino pin 9 and 10?

    I have built the range finder and is almost ready to test it.

  23. NatureTM says:

    Thanks for sharing this, kwong! This was a project I had been pondering for awhile, but I thought it might have been beyond my abilities. I certainly wouldn’t have been able to design the receiver circuit.

    I ordered enough parts for 10 transmitters and 10 receivers. Right now, I’m just waiting for the ultrasonic transceivers to arrive from Electronic Goldmine. I plan to make just one of your rangefinders in order to familiarize myself. After that, I’d like to tinker a bit.

    I’d really like to try implementing some type of beamforming from 2 or 3 transmitters. I’m also thinking about trying to triangulate the position of a transmitter using multiple receivers. They both sound like relatively straightforward trigonometry problems, but I have a feeling it might not be so easy.

  24. akash says:

    thanks for the circuit…. Sir can i use 741C op amp in place f Lpc662

  25. switch says:

    Thank you for the very nice presentation, Sir. I’ll be creating one in a few days and I’m very excited to see the results.

    I have a couple of questions though. One, regarding your Rx circuit. Only 40kHz transducers are available in my area and I’m not inclined on shipping stuff for a simple project. So, aside from the RC pairs that control the cut-off frequencies, is there anything else I must adjust/change if I were to work with a 40kHz transducer?

    The other one concerns the microcontroller. I only have an Arduino Mega at my disposal. Will the resolution of its micros() command be equal to the resolution using yours? Will this affect ranging calculation? The Arduino Mega uses an ATmega1280 and operates with a 16MHz clock.

    Thanks in advance for the helpful response!

  26. akash says:

    sir, iam getting sme garbage value as the op f circuit, d only change i made is lm358 in place f lpc662 nd 40 khz for 24 khz

    • kwong says:

      Did you use an oscilloscope to view the output waveform? Also, did you change the RC constants to compensate for the 40kHz ultrasonic sensor?

      Depending on your particular application, you might need to use an LC filter to decouple your power source (I updated in a post here). Also, for the Op-amp voltage divider, you can add a bypass cap to improve the virtual ground stability.

  27. akash says:

    i’am a beginner, can u specify the capacitance and resistance to be changed, nd how they should be changed. Pls reply…! Am doing this circuit as my projct…

    • kwong says:

      I’ll post the parameters for 40KHz operations later today. If you don’t have a scope handy, it will be a bit tricky to pin-point the problem. I would highly recommend you test your amplifier with a signal generator first (i.e. output a 40KHz pulse @1mV and measure the output to see if you get any clean output).

  28. akash says:

    thank U sir for all your help and support.
    i finally got the circuit working.
    but after a specific range of about 300 cm readibgs become random and unpredictable,
    the min distance that can be measured is 19cm…….

    • kwong says:

      Glad it worked. The sensitivity of the transducer may vary from brand to brand. If you could (you need to consult the datasheet), you can drive the transducer at higher voltage (e.g. 12V) and that will significantly boost the range.

  29. Sultan says:

    The GH-311 ultrasonic modules are rarely available now. I dont know whatz the reason behind it. If this project would be modified to use with some small microcontroller, certainly it will be easier to construct as well in the pocket. ATtiny 13, PIC12F508, AT89C2051 or any such micro may be considered in place of costly Atmega 328.

  30. TalhoSan says:

    Hi! Thank you for these schematics, source code and for the description of this circuit. I think, I am going to build this, becaouse this is cheaper than the Parallax Ping))). I have a few thing what I would like to know first.
    1., There is a 30cm ~1 feet black spot (shortest measurable distance) in this project. Can I reduce this distance somehow? Like reducing the 1 millisecond delay to 500 microsecond or some other way? For me ~15cm ~0,5 feet shortest measurable distance would be enough.
    2., The 2N3904 and 2N3906 transistors can get warm during normal operation. The 5 V VCC is enough for me (20 feet distance is almost too much). I would like to play it safe so what kind of transistors should I use to reduce the heat dissipation?
    3., Where I live the 2N3904 and 2N3906 are a little hard to buy. Its not impossible, but I would like to something wich is easyer to buy.

    Thank you for aour help!

    • kwong says:

      In order to reduce the blind spot, you will need to add some sort of dampening circuits (i.e. RLC) in parallel with the transducer. Even so, it would be quite tough to reduce the blind spot down to 15cm with a maximum range of 20 ti 30 feet. But if you only require a range of 5 feet, you can reduce the driving power (e.g. drive with a single transistor instead of the bridge).

      In terms of the choice of transistors, pretty much any general purpose transistors with an Ic larger than 200mA and BVceo greater than 20V should do the job.

      • TalhoSan says:

        Hi!
        I don’t want to measure things wich is 20 or 30 feet away. For me if the measuring is fairly accurate between 0,5 feet and ~10 feet is more than enough. I don’t want it to be accurate on a mm scale.
        There is something what I want to ask. I have a few LM258N amplifiers. Can I use the intead of the LPC662 or the LM358?
        Another thing. Can I use the BCV 47 and BCV 46 transistors instead of 2N3904 and 2N3906? Its easyer to me to buy, cheap and can handle mor power (not that I need it), they dissipate less power.

        Thank you for your help again!

        • kwong says:

          You can change the transistors to BCV46, 47 without any issue. LM258N has a pretty low unit gain bandwidth (around 1MHz) and would not be suitable for this high gain application for the desired bandwidth. You’d need to find an op-amp with a wider bandwidth (e.g. 10 MHz).

  31. winneymj says:

    Hi,
    I am new to this stuff, and wish to build one of these circuits, but with so many different capacitor types could someone please list the types of capacitors that are being used in the receiver circuit.
    I have seen some circuits that say to use polyester film capacitors as they are more accurate.
    What capacitor types are the:
    6.8nF
    33pF
    1uF
    0.1uF

    Thanks for any help

  32. Fino says:

    Hi, great explanation!
    I want to ask about the detail of the H bridge circuit.
    Where should I put the additional capacitors and resistors?

  33. Peter says:

    Thanks for this post. I found it interesting if not somewhat difficult since my electronics is weak and programing skill is none. You mention similar products are very expensive, seeing the skill one requires to come up with this, is understandable. Great job!! Thanks again and hope you keep bringing these type of DIY “lessons” to all of us.

  34. Michi says:

    First of all thanks for sharing your experience.
    I need some sensors in order to detect people and
    I am wondering how far a person can be detected aproximatly.
    It would be great if anyone could evaluate it.

    thank you

    • kwong says:

      For person detection, it seems that there are other better methods (e.g. PIR sensor) than ultrasonic sensor. Depending on what a person is wearing, the detection range could vary drastically due to absorption of the clothing materials…

  35. raron says:

    Hi!

    Just something I noticed right now, regarding the output bridge:

    “For even longer range measurement, you can safely increase this driving voltage to around 12 Volts as most ultrasonic transducers can be driven with voltage as high as 20 to 30 volts”

    While the transducers can be driven safely, that particular bridge design would not work with higher voltage than 5V, as the top-right PNP transistor in the schematic would never turn off. And also the arduino output would be shorted (or get current input from a higher voltage source).

    But very nice design, good work! Thanks for sharing! :)

    • kwong says:

      Good point! Thanks for the feedback!

      In this case, the drive voltage to the bridge will have to be level-shifted first.

      • andrew says:

        Hi kwong,

        I would like to push the range as high as possible. Ill increase the driving voltage to around 12V so I’ll use 2N2222 instead of 2N3904 and 2N2906 instead of 2N3906.

        Could you post a cct mod that fixes the issues Raron mentioned… (that the bridge design would not work with higher voltage than 5V, as the top-right PNP transistor in the schematic would never turn off and that the arduino output would be shorted).

        Do you also agree with Jhonny’s comment (February 26, 2011 at 6:55 pm) about getting a better SNR by rearranging the first amplifier as non-inverting and use a high value bias resistor (MOhm) to Vcc/2 ? Would this improve range and accuracy?

        Are are 40kHz transducers going to improve range, or just accuracy when used instead of 20kHz?

        Finally, I intend to use a minimal (read ‘cheapest’) PIC/programmer for this project as I’ll be making a bunch of them. Would that be the ATmega168? Are there any other minimal PICs that you would recommend specifically for this task?

        Thanks, Kwong, for your very informative site and help.

        • kwong says:

          Hi Andrew,

          To use voltage higher than 5V, you will need to amply the drive signal from 0-5V to 0-Vcc (if you are using 12V then Vcc would be 12V). The simplest way to do this is to add a transistor stage so the drive signal would be amplified to 0-Vcc. Yes, if you use a non-inverting arrangement, it would have higher input impedance. I guess that was something I overlooked when I designed the circuit. The frequency of the transducer has little to do with the range (yes, higher frequency will result in slightly better resolution), you might want to check the maximum output power of the transducer and the max drive voltage. If you are going to use PICs, you could use PIC16 and PIC18 chips, but you will have to re-write the code. If you are staying with ATmega, then yes ATmega168 should be sufficient.

  36. Hatim says:

    Hello,

    Can I swap a 2N3904 transistor with a 2N2222 transistor. If I do, will I have to swap all the 2N3904? Or will swapping one 2N3904.

    Yours sincerely,

    • kwong says:

      Absolutely, 2N2222 has an max Ic of 1A it should be even better. But I’d suggest you use a complementary PNP transistor that has similar specs such as 2N2906 instead of using 2N3906. I wouldn’t recommend just changing one transistor however.

  37. xozip_neutron says:

    sir, can i use my tl072 dual op-amp? and i am planning to connect it to pin3 because pins 11, 10, 6, 5 are used for my motor driver… what part/s of the should i change? thanks for the help..

  38. HGurel says:

    Hello , first thanks for sharing this project. I want to ask that what other microcontroller can use in this project? atmega328 are little hard to find in my country and little expensive to have it shipped here. But I can access atmega8 or 16 and most of the PIC series.Im a beginner at electronics , sorry if my question is weird. Thanks in advance

  39. xozip_neutron says:

    sir, im confused… :) im just new with this stuff.
    what part of the sketch should I change? I want to connect the TX to digital pin 3…

    • kwong says:

      I see what you were trying to do now… the sample code uses ATmega328’s counter 1 PWM output, since ATmega328 only has one 16bit counter, you cannot change the output pin (in this case it’s Arduino pin 10) without having to totally rewrite the PWM code…

      • xozip_neutron says:

        sir kwong, my arduino uses ATmega168, does it also have a 16bit counter? pin 9 belongs to counter 1 sir right? does it mean that i cannot use this PWM pin to my H-Bridge?

        • kwong says:

          The counters on ATmega168 and 328 are the same (the only difference between the two is the flash memory size). If you use the PWM pin for the sensor, you will have to use the other PWM pins for your H-bridge.

  40. xozip_neutron says:

    okay sir, thank you very much…

  41. francis says:

    hey the lpc662 chip is there any replacements coz i cant find that chip anywhere!!!?? and there are two outputs for the sensor right? (receiver and transmitter together)? so is there any way we can make it into one output like the pin ultrasonic sensor?
    /???

  42. Radhika says:

    What will happen if I use IC NE567 after the op-amps?……Will the output be analog or digital?…..And will i be able to interface it with Arduino then??? Please do reply.

  43. PsyPi says:

    Thanks for this amazing circuit! I got on to making it immediately when I saw this. It’s much easier than other similar circuits!

  44. mukesh says:

    hi friends kindly help me. i am doing a project in which i need to interface ping)) with telosb which has msp430 processor. and how to write code for it.
    kindly mail me @ mkpandey.irs@gmail.com

  45. sudheera says:

    Nice work Sir..,

    Can you please explain what are the modification required to achieve 2ft max range sensor using this circuit (GH-311). I’m using 40kHz, and arduino mega. Thank you.

  46. hardevsinh jadeja says:

    sir im a beginner….would you pls give me some idea about the circuit operation,,,,?

  47. cindylky says:

    Hi. I’m actually looking ultrasonic sensor that can used to measure distance between range above 10 meters, or like 10-20 meters. Can sir give a suggestion or is there any others types of ultrasonic sensor that can measures that kind of range that I mentioned? Thanks in advanced.

  48. francis says:

    sir is there any replacement for the lpc662 chip coz i cant find that chip anywhere!!!?? and there are two outputs for the sensor right? (receiver and transmitter together)? so is there any way we can make it into one output like the ping ultrasonic sensor?
    /???
    thanku sir!

Leave a Reply