Audio frequency setting

Hello How is it possible to adjust the sound on atmega 32u4 by adjusting frequency to precision hertz? It is to tune for musical instrument

Thank you

[u]tone()[/u] should be plenty accurate-enough to tune an instrument (parts-per-million) based on the Arduino's oscillator/resonator. And if it's off a little it should still be stable so you can "calibrate it"... i.e. If it's 1% too high, you put-in a correction factor and program tone(336) if you want 440Hz.

But... I'm not sure if it's hard to tune to a square wave, and the Arduino doesn't have a DAC so it can't make sine waves...

Also, the Arduino needs an amplifier to drive a speaker (or you can use amplified computer speakers). The Arduino can directly drive a piezo transducer but at mid-frequencies (i.e. 440Hz) the harmonics are probably going to be stronger than the fundamental.

If you want to experiment and you don't have an Arduino set-up with a speaker/transducer already, it might be easier to generate a square wave with [u]Audacity[/u].

P.S. Or, maybe just get a tuning fork... Cheap, reliable, accurate, no batteries, and it lasts a lifetime! :D :D :D

Take a look at this project - I used blink without delay style programming and microsecond timing to create organ-like tones that were very much in tune with my wife's baby grand piano. Reply #4 has the code and schematic for passing the output to a self powered computer speaker, and there's a you tube video as well.