1

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 either?

Code snippet:

pinMode(3,INPUT); // Signal input to Arduino from pin 2 on LM339 - D3
int pwindow = 6000; // Maximum timeout value for pulsewidth
long pcounterA = 0; // Unfiltered Pulse Width of Channel 1
pcounterA = pulseIn(3,LOW,pwindow);
Serial.print(pcounterA);

Thanks for any help. JT

asked Apr 2, 2018 at 19:06
1
  • 1
    Slight nitpick: mHz is millihertz; MHz is megahertz. That's a difference of 9 orders of magnitude. Commented Apr 2, 2018 at 23:06

1 Answer 1

3

According the official Arduino Reference: PulseIn

Fragment:

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. Gives up and returns 0 if no pulse starts within a specified time out.

answered Apr 2, 2018 at 19:08
1
  • 2
    Further, from that same page, **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. ** Commented Apr 2, 2018 at 19:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.