NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7

bulut:
believe me if we apply the 16 pulses with 21us period with 40KHZ frequency i will be work i am sure, so please tell me how to change the code to produce this pulses .

The NewPing library doesn't do the ultrasonic pulses. It only triggers the control board which does the pulses. It's very odd that this control board doesn't do these pulses (that's one of the duties of the control board). I've never heard of a control board that doesn't do the required pulses that the control board's decoder requires. It only makes sense that the control board would issue the correct pulses that it needs on the decode side. It could be how you're doing the ping trigger. Maybe you're not doing the trigger, but actually just a single fire? In other words, maybe you're connecting to the wrong place on the control board.

In any case, doing these pulses is outside the scope of the NewPing library as it would drastically change things and be specific to one individual control board.

What you'll need to do is create your own control function or library. In order to do the pulses with accuracy, you'll need to look into PWM. I don't think the standard Arduino PWM will work as you need to set a frequency of around 47 kHz (21uS) while the maximum Arduino PWM is 1 kHz. Using timers you can get as high as 64 kHz, but I believe the next step would be 32 kHz so you could still have a problem.

I'd really try to get the control board to do the correct pulses (that's its job anyway). If you can't, try looking for PWM library that can do high frequency pulses.

Tim