Go Down

Topic: Help, Code for reading Frequency (Read 625 times) previous topic - next topic

NOOB4101

Ok please forgive me, i am very noobish ... i actually need to ask a question but not sure how to start it as a topic like he did up there..


i need a simple program where i can read a frequency, no need to display it.
ill read it if its above 500hz an led light up,
and if its below 500hz another led from another pin light up.. of course i am not going to ask u guys to do this for me but i will try my self in the cod below... please forgive my obvious syntax error.

Code: [Select]
#include <FreqMeasure.h>
int led1=13;
int led2=9;
void setup() {
FreqMeasure.begin();
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
}

if (FreqMeasure.available()< 500)
  digitalWrite(led1,HIGH)
else
digitalWrite(led2,HIGH)
end

will this work ?


just a clarification for the library , i got it from this site http://www.pjrc.com/teensy/td_libs_FreqMeasure.html#compare , and i place it in my libraries folder within the audrino upload, is this right ?

CrossRoads

Need to put this part within void loop:
Code: [Select]

void loop(){
if (FreqMeasure.available()< 500){
 digitalWrite(led1,HIGH);
}
else{
digitalWrite(led2,HIGH);
}

} // end loop

and then add some logic to turn the LEDs off, other wise once on they will stay on.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Go Up