Go Down

Topic: Pulsein on Analog Pins (Read 513 times) previous topic - next topic

Paulinho19

Hi,

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


Code: [Select]
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);

}

retrolefty

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

holmes4

Pulsein is for the digital pins pins only

From the ref section for Pulseln()

Quote
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

AWOL

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

Code: [Select]
pinMode(Pin, INPUT); //Pin 14 as input
It isn't an analogue input.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

robtillaart


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...

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up