Go Down

Topic: function pulseIn(pin, value, timeout) doesn't work? (Read 89 times) previous topic - next topic

I use ultrasonic to measure the distance.

1) pulseIn(pin, value) - working, but not as documentation describe it: timeout "default is one second"

I have only 450 us pause to start capture the pulse.

1) pulseIn(pin, value, timeout) - returns 0 with any value of timeout

robtillaart

please post your code and schematic.

what board are you using?
which version of the IDE?

1) timeout does not have a default value,

PulseIn() is a less accurate functions:

2) timeout is in microseconds and INCLUDES the waiting time before the pulse
3) different versions of the compiler optimizes the code differently causing up to 15% deviation
4) it contains hard coded magic numbers e.g. 16 for clock which is not always true.

Think the pulseIn() code is reasonably valid for 16MHZ UNO and MEGA but not for ARM


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy