1

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
asked Aug 12, 2020 at 6:46
2

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.