Go Down

Topic: Read a freqency from an analog pin (Read 3 times) previous topic - next topic

florin

Hi!
I want to read some frequnces, but i do not know how i can do it. For example: if freq=20 hertz, blink a LED. Any oppinions?

PaulS

Quote
I want to read some frequnces, but i do not know how i can do it. For example: if freq=20 hertz, blink a LED. Any oppinions?

The frequency of a PWM pin is a constant.

florin

Sorry, an analog pin.I want to read a frquency.

retrolefty


Sorry, an analog pin.I want to read a frquency.


Difficult and time consuming to try and measure the frequency of a analog signal with a analog input pin. Better to run the signal to a comparator op-amp circuit and measure the frequency as a digital on and off signal. What is the waveform of your signal (sinewave, square wave, random audio) ? What is it's voltage range min to max, AC or DC?

Perhaps if you told us what you are trying to accomplish in the sketch rather then what method you think will work best, we can better try and help you.

Lefty

CrossRoads

Digital signal, or analog?
Best bet is to get it digital - then can use the Pulsein() commands to measure the high time, measure the low time, add the two together for the period. 1/period = frequency.
Or using the rising edge to create  a PCINT, measure the time from PCINT to PCINT, do the same math.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up