Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have seen some tutorials on ultrasonic range detector sensor.

In that, what is the meaning of the word pulseIn?

share|improve this question

pulseIn() is used to Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or 0 if no complete pulse was received within the timeout.

The timing of this function has been determined empirically and will probably show errors in shorter pulses. Works on pulses from 10 microseconds to 3 minutes in length. Please also note that if the pin is already high when the function is called, it will wait for the pin to go LOW and then HIGH before it starts counting. This routine can be used only if interrupts are activated. Furthermore the highest resolution is obtained with short intervals.

Syntax

pulseIn(pin, value) 
pulseIn(pin, value, timeout)

Parameters

pin: the number of the pin on which you want to read the pulse. (int)

value: type of pulse to read: either HIGH or LOW. (int)

timeout (optional): the number of microseconds to wait for the pulse to be completed: the function returns 0 if no complete pulse was received within the timeout. Default is one second (unsigned long).

Returns

The length of the pulse (in microseconds) or 0 if no pulse is completed before the timeout (unsigned long).

For additional information and example code, visit: https://www.arduino.cc/en/Reference/PulseIn, hope this help you to understand the meaning of pulseIn().

share|improve this answer
    
Why are you copying directly from the reference page? What is the added value? – Mikael Patel 22 hours ago
    
@MikaelPatel you are right, there isn't any added value. Anyway, I believe that the information contained in my answer can better help people inside the community to have knowledge of the function explained. – Mattia 22 hours ago
    
But you have simply copied the text directly from the reference page. And skipped the important example code! – Mikael Patel 22 hours ago
    
@MikaelPatel you can edit the answer if you want to improve it with additional information. Or if you prefer you can also write a new answer. – Mattia 21 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.