Go Down

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

#### Paulinho19

##### Dec 14, 2012, 02:29 am
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 lengthvoid 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

#1
##### Dec 14, 2012, 02:57 am
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

#2
##### Dec 14, 2012, 11:41 am
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

#3
##### Dec 14, 2012, 11:54 am
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.
I speak for myself, not Arduino.

#### robtillaart

#4
##### Dec 14, 2012, 08:19 pm

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