I am trying to understand how tone function works. seems like I can use tone function in a non-PWM channel as well. can you please explain how tome() function was written? If a timer was used then how that was implemented?
vahid tajari
1,29813 silver badges23 bronze badges
1 Answer 1
The function uses timer interrupts to toggle an output pin.
The timer is set up using the frequency parameter. In the toneBegin function
The pin is toggled for a number of times that is calculated from duration and frequency.
https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/Tone.cpp
answered Aug 12, 2020 at 7:16
Piglet
29.3k3 gold badges31 silver badges51 bronze badges
Sign up to request clarification or add additional context in comments.
tone: github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/…