some tweaks

This commit is contained in:
Alexey Skobkin 2013-07-28 07:46:26 +04:00
parent 3def7bd1c8
commit d1f415638b

View file

@ -1,24 +1,24 @@
int edge = 15; const int edge = 10;
const long d = 5; const long d = 10;
int analogInPin = A0; const int analogInPin = A0;
const int audioOutPin = 12; const int audioOutPin = 12;
void setup() { void setup() {
Serial.begin(115200); //Serial.begin(115200);
} }
void loop() { void loop() {
int freq = measureFrequency(); long freq = measureFrequency();
if (freq != 0) if (freq != 0)
tone(audioOutPin, freq); tone(audioOutPin, freq);
else else
noTone(audioOutPin); noTone(audioOutPin);
Serial.println(freq); //Serial.println(freq);
} }
int measureFrequency() { long measureFrequency() {
long t = millis(); long t = millis();
int n = 0; long n = 0;
boolean o = analogRead(analogInPin) <= edge; boolean o = analogRead(analogInPin) <= edge;
while(millis() - t <= d) while(millis() - t <= d)