mirror of
https://bitbucket.org/skobkin/arduino_guitar_repeater.git
synced 2024-11-22 04:16:02 +00:00
some tweaks
This commit is contained in:
parent
3def7bd1c8
commit
d1f415638b
16
guitar.ino
16
guitar.ino
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue