I made a simple music program using an arduino Uno and the tone() function. It works fine.

I decided to build my own circuit using a barebones AVR and upload that program. I did not know exactly what frequency was being used by the arduino, so I used a Murata resonator, with a frequency of 8 MHz.

When I put my circuit to the test, the music that I had generated was played an octave lower, and its duration was doubled (taking twice the time to finish played a note).

I figured out that I used the wrong resonator frequency. Indeed, I found out that the Arduino Uno used a 16 MHz resonator. Since I had half that frequency in my clock, the tone would be lower frequency, and it would take twice the time to finish a note. This made sense.

So I went ahead and rebuilt the circuit with a 16 MHz resonator frequency. However, now I have the opposite effect!

All the notes are one octave higher compared to my original Arduino Uno design, and the note duration finished in hald the time compared to the original Arduino Uno design... This suggests that I now have doubled the frequency compared to the original design (and four times the frequency compared to my first custum circuit attempt).

I cannot seem to understand why this is happening, because right now I have the frequency that the original Arduino uses....

1 Answer 1


If the code runs at twice at the expected speed when clocked at 16 MHz, this can only be because either:

  • you fixed the program to run correctly when clocked at 8 MHz
  • you told the IDE that you are using a 8 MHz clock.

The IDE comes with a few configurations that are suitable for an 8 MHz clock. If you select as a board “Arduino Pro or Pro Mini”, you have something equivalent to an Arduino Uno, except that you can choose between an 8 MHz clock and a 16 MHz clock (and also between an ATmega168 and a 328P).

  • Thanks! That was it! Oct 9, 2023 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.