Hi! What is the maximum hertz for the tone() function? Thanks!
Bump. Really want an answer! thx.
You failed to indicate which board / processor so I will (sort of) answer for the AVR family.
https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Arduino.h#L236
The frequency parameter is unsigned int. An unsigned int is 16 bits. The maximum value for an unsigned 16 bit integer is?
65,536?
Also, it's with a RedBoard(basically arduino uno with a little higher maximum input voltage). Atmega328pu
bobdabiulder:
65,536?
The Great and Wise Gorcle disagrees (notice this is the exact question I posed)...
https://www.google.com/search?q=The+maximum+value+for+an+unsigned+16+bit+integer+is%3F
Second hit looks promising.
Thanks!
You are welcome.
In addition, there is a limit imposed by the number of available divisors. For a frequency of 65535 Hz we need a divisor of...
16000000 / 65535 = 244.144350347
However, divisors can only be integers. The next nearest higher divisor is 245 so the actual frequency will be...
16000000 / 245 = 65306.122449 Hz