Questions tagged [pulsein]

refers to the function pulseIn().

Description

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)

35 questions
2
votes
2 answers

How do I use two PulseIn() functions simultaneously in Arduino?

I want to connect multiple Ultrasonic sensors to my Arduino board. For that, I need multiple pulseIn() functions to work at the same time. How can I do that?
Mat_python
  • 56
  • 2
  • 4
1
vote
1 answer

Pulsein not working when share ground

I have 3rd party device that create PWM output which I want to measure it with Arduino, the problem I have is when I shared ground between the two boards which cause the Pulsein output to become zero. (why this is happening, and how to fix it) The…
Shahreza
  • 165
  • 9
1
vote
1 answer

When does the pulsein() function start counting?

I have an Arduino Pro mini 3.3V, 8 mHz and I want to use the pulsein() function for a low-going pulse. My question: Does the timer start when the function senses a LOW on the input pin, or when the function senses a high-to-low transition, or…
j t
  • 11
  • 1
1
vote
2 answers

PulseIn tachometer

I tried to create a tachometer for my motorcycle using an Arduino Uno. I am trying to measure the voltage of the ignition coil (stepped down to not destroy the Arduino). I am trying to determine the time between two explosions (one ignition coil…
0
votes
1 answer

PulseIN not recognised

I have included the library for the HCSR04 echo sounder, but pulseIN is not recognised; it never goes orange either. I have tried multiple libraries, and closing down the IDE and opening it back up.
Neil
  • 1
0
votes
1 answer

Can an Arduino Uno be used to measure the frequency of a square wave of up to 600 kHz?

I am doing a project with a color sensor, where the output of the color sensor is a PWM square wave. To measure its frequency using an Arduino Uno I am using the pulseIn() function, but I can't get the correct result. Can an Arduino Uno measure a…
0
votes
1 answer

How to pulse a signal at 100ms to 500ms?

Based on this PDF I need to pulse between 100ms and 500ms to record a video (the description is apparently wrong according to this guy). How would I generate such a pulse? The small module has 3 wires I can use, which are positive, ground, and a…
MortenMoulder
  • 353
  • 1
  • 8
  • 19