Hi folks,
the PING))) ultrasonic range finder measures distances from 3cm to 3meters. But I`d have to limit its range from 3cm to 60cm.
Thus I want the program to wait for a maximum duration of 3496 microseconds (=60cm) before automatically going LOW again. How could I start a timecount in microseconds each time the PING))) goes HIGH??? This would allow me to go LOW after the desired duration.
As far as Im concerned *pulseIn(pin, HIGH)* wont work, as pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. So untouched it always outputs the sensor's maximum range, as it needs an echo to stop timing and else gives the sensor's maximum range.
Hi billroy,
good thinkig hear, I checked that before posting my question and unfortunately the answer is no. timeout waits the number of microseconds for the pulse to start, in other words: timeout returns 0 if no pulse started before the timeout. Thus it counts the time before the sensor goes HIGH, but I`d like to count the time in microseonds the moment the sensor goes HIGH until it reaches 60 cm or receives an echo before that.
???
Hi AWOL,
sorry for asking, but I didn`t fully understand your reply.
Did you mean I should rewrite/modify the pulseIn() function?
If yes, how can I get its source code?
Never rewrote a function before, but actually sounds like a good idea.