Pulsein on Analog Pins

Hi,

is there an explanation why the pulsein() function doesn’t work on the analogpins?

int Pin = 14;  // Analog PIN 0 

int pulse;  // store RC signal pulse length


void setup()
{
  Serial.begin(9600); //serial library start
  
  pinMode(Pin, INPUT); //Pin 14 as input

}


void loop()
{  
  pulse = pulseIn(Pin, HIGH, 20000); 
  Serial.print ("Pulse Time: ");
  Serial.println (pulse);

}

What and how are you wiring what up to the analog input pin? Perhaps if it's a simple switch you have a floating input pin condition? Draw us the electrical hook-up your using for that pin.

Lefty

Pulsein is for the digital pins pins only

From the ref section for Pulseln()

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.

It makes no sense to try to no this with an analog input.

Mark

It makes no sense to try to no this with an analog input.

pinMode(Pin, INPUT); //Pin 14 as input

It isn't an analogue input.

What is the output you get?
What did you expect?

Which version of the IDE are you using as in older versions there was at least one bug in the PulseIn() code...