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
-
1Slight nitpick: mHz is millihertz; MHz is megahertz. That's a difference of 9 orders of magnitude.AaronD– AaronD2018年04月02日 23:06:54 +00:00Commented Apr 2, 2018 at 23:06
1 Answer 1
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.
-
2Further, 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. **jose can u c– jose can u c2018年04月02日 19:09:43 +00:00Commented Apr 2, 2018 at 19:09