Pulsein alternative for analog pins

There's any way to do the same as pulsein function on analog pins?
I'm trying to use Arduino as frequency measure and osciloscope at same time for same signal and I used a0 as input pin

What do you want this analogue pulseIn() function to do exactly ?

Is for frequency calculation like this snippet

pulseHigh = pulseIn(pulsePin, HIGH);

pulseLow = pulseIn(pulsePin, LOW);

pulseTotal = pulseHigh + pulseLow; // Time period of the pulse in microseconds

frequency = 1000000 / pulseTotal; // Frequency in Hertz (Hz)

So it is the normal pulseIn() function used with an analogue pin being used as a digital pin

We can't get the right reading that way

Why not ?

Probably because this function only works with digitalpins as writes on documentation.

As has been explained, analogue pins can be used as digital pins

1 Like

Let me see if I understand what it is you are trying to do:

  1. You want to put an analog signal into A0.
  2. You want to use the result of analogRead(A0) to populate the data on some sort of digital oscilloscope.
  3. You want the Arduino to somehow treat that analog signal as a digital signal simultaneously, and measure its period.

Have I got that about right?

In the 3 point I want to measure the frequency

Here's what's writes on documentation that says that pulsein is for digital pins

ONE MORE TIME

Analog pins can be used as digital pins

What you can't do is to use a pin of any kind as both an analogue and digital input at the same time

You can use pulsein on Uno's A0 pin.
Do not argue again, just try it yourself, bro!

Does your input signal go low enough for Arduino to recognize it as digital LOW? Does it go high enough for Arduino to recognize it as digital HIGH? Connect the signal to 2 input pins, one digital, one analog.

Probably that's the problem

I'm sorry, but you did not answer the question. And I'm afraid your statement is not possible. You can use pulseIn on a digital input to measure period, and calculate frequency from that. You cannot measure frequency directly using pulseIn, as you yourself demonstrated in post #4.

So my code snippet is wrong. But yes I want to calc frequency or period.

Please state the voltage range of the signal (maximum and minimum).

Maximum voltage 1mV Minimum voltage 0.1mV

You will need an amplifier for a 0 to 1 mV signal.

A "rail to rail" operational amplifier with a gain of 1000 to 5000 should work.