florin:
Now ,it is correct?#include <FreqCounter.h>
double frequency;
void setup() {
pinMode(5,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(15,OUTPUT);
pinMode(16,OUTPUT);
pinMode(17,OUTPUT);
}
void loop() {
long getFrequency(A0);
{
#define SAMPLES 4096
long freq = 0;
for(unsigned int j=0; j<SAMPLES; j++)
{
freq+= 500000/pulseIn(A0, HIGH, 250000);
}
frequency = freq/SAMPLES;
if (frequency <5000)
{
digitalWrite(5, HIGH);
digitalWrite(11,HIGH);
}
if (frequency >5000)
{
digitalWrite(12, HIGH);
digitalWrite(15,HIGH);
}
}
}
Did you actually make any changes...?
For your reference:
Wikipedia:
Frequency is the number of occurrences of a repeating event per unit time. It is also referred to as temporal frequency. The period is the duration of one cycle in a repeating event, so the period is the reciprocal of the frequency. For example, if a newborn baby's heart beats at a frequency of 120 times a minute, its period (the interval between beats) is half a second.
... and ...
Wikipedia:
In mathematics, a multiplicative inverse or reciprocal for a number x, denoted by 1/x or x−1, is a number which when multiplied by x yields the multiplicative identity, 1. The multiplicative inverse of a fraction a/b is b/a. For the multiplicative inverse of a real number, divide 1 by the number. For example, the reciprocal of 5 is one fifth (1/5 or 0.2), and the reciprocal of 0.25 is 1 divided by 0.25, or 4. The reciprocal function, the function f(x) that maps x to 1/x, is one of the simplest examples of a function which is self-inverse.