Good day, Masters! I really need your help on this one as the circuit will be due this week
=(
I'm using Arduino UNO and MEAS Piezo Vibration Sensor from SparkFun
I have been searching the web on how to measure frequency using a piezo vibration sensor and nothing worked because they said it is only good as a detector and it is not meant to measure frequency. But Sir Magician helped me find a code and it works perfectly
the frequency increases the harder you blow on the sensor, just what I needed. Thank you again Sir!
The problem now is, it uses 3 digital pins; uses arduino's internal analog comparator(for Pin 6 and 7) and alternate port function T1 (for Pin 5) which is the input 16 Bit Hardware Counter1
I read about Analog Comparator here -> http://www.instructables.com/id/Girino-Fast-Arduino-Oscilloscope/step11/How-the-Analog-Comparator-works/
"The Analog Comparator is an internal module of the microcontroller and it compares the input values on the positive pin (Digital Pin 6) and negative pin (Digital Pin 7). When the voltage on the positive pin is higher than the voltage on the negative pin AIN1, the Analog Comparator outputs a 1 in the ACO bit of the ACSR register."
and function T1 here -> http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/
"The Frequency input is fixed to digital pin 5. This pin is mapped to the alternate port function T1 which is the input 16 Bit Hardware Counter1. To obtain a higher resolution than 16 Bit, the counter overflows are counted also and are calculated with the counter value to the final long integer result."
This means, I can only read one vibration sensor per Arduino. And I need to read at least three.
I need your advice on what components to use on this project.
Here's the site Sir Magician gave me
http://interface.khm.de/index.php/lab/experiments/frequency-measurement-library/

<Click here for larger image http://interface.khm.de/wp-content/uploads/2010/06/FreqPeriodSch05.jpg>
/* Frequency & Period Measurement for Audio
* connect pin 5,6,7 to input circuit
*
*
*
* KHM 2010 / Martin Nawrath
* Kunsthochschule fuer Medien Koeln
* Academy of Media Arts Cologne
*/
#include "FreqPeriod.h"
double lfrq;
long int pp;
void setup() {
Serial.begin(115200);
FreqPeriod::begin();
Serial.println("FreqPeriod Library Test");
}
void loop() {
pp=FreqPeriod::getPeriod();
if (pp ){
Serial.print("period: ");
Serial.print(pp);
Serial.print(" 1/16us / frequency: ");
lfrq= 16000400.0 / pp;
printDouble(lfrq,6);
Serial.print(" Hz");
Serial.println(" ");
}
}
//***************************************************************************
void printDouble( double val, byte precision){
// prints val with number of decimal places determine by precision
// precision is a number from 0 to 6 indicating the desired decimial places
// example: lcdPrintDouble( 3.1415, 2); // prints 3.14 (two decimal places)
if(val < 0.0){
Serial.print('-');
val = -val;
}
Serial.print (int(val)); //prints the int part
if( precision > 0) {
Serial.print("."); // print the decimal point
unsigned long frac;
unsigned long mult = 1;
byte padding = precision -1;
while(precision--)
mult *=10;
if(val >= 0)
frac = (val - int(val)) * mult;
else
frac = (int(val)- val ) * mult;
unsigned long frac1 = frac;
while( frac1 /= 10 )
padding--;
while( padding--)
Serial.print("0");
Serial.print(frac,DEC) ;
}
}