Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/tuner #2

Merged
merged 9 commits into from
Feb 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
der beste Tuner bisher
baartch committed Feb 14, 2020
commit 32c133a24020270d98442a7fb0325bdd1e13f139
50 changes: 50 additions & 0 deletions freq.ino_
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//Credits: http://www.breadboarding.de/frequenzmessung-arduino/

int zaehler;
unsigned long timer;
unsigned long timerOld;
unsigned long startzeit;
unsigned long messzeit = 1000000;

void setup(){

Serial.begin(9600);


}


void loop(){
if ((micros() - startzeit) >= messzeit)
{
float f = timer; //Datentyp 'float', wegen untenstehender Division
f = 1000000/f; //Aus Periodendauer Frequenz berechnen
detachInterrupt(0);
if(f >= 300){
Serial.print("Zaehler: ");
Serial.println(zaehler);
}
else if(f < 300 && f >= 30){
Serial.print("Messung: ");
Serial.println(f, 1);
}
else if(f < 30 && f >= 3){
Serial.print("Messung: ");
Serial.println(f, 3);
}
else if(f < 3){
Serial.print("Messung: ");
Serial.println(f, 5);
}
attachInterrupt(digitalPinToInterrupt(2), Messung, RISING);
zaehler = 0; //Frequenzzähler zurücksetzen
startzeit = micros(); //Zeitpunkt der letzten Ausgabe speichern
}
}

void Messung()
{
zaehler++;
timer = micros() - timerOld;
timerOld = micros();
}