PWM, timers and Tone()

Hey all,

I have a project that utilizes tone() and also PWM of an LED strip. I am getting 'interference' when the speaker is playing a tone that is consistent with the flash of the leds. I figured this was a conflict issues. I got the toneAC() library which I think utilizes a different timer for the audio. That fixed my problem. However the two pin set up of toneAC may be a problem as I need to amplify to a 12v speaker.

So how do I enable the ability to change the timer used for the speaker like the toneAC library does. Or would it be more simple to try and keep toneAC and amplify it. Im just not sure how to amp a two out put pin setup like toneAC requires.


PS and yes I do have capacitors its definitely a timer issue.

Sadly you did not post any code, so any advice must necessarily be of a general nature. If this does not suit your situation please advise our consultants. :stuck_out_tongue:

How to use this forum

I wrote a library that outputs tones using Timer 1 but no interrupts. If you have Timer 1 free you might use that.

Yeah this general in nature. I think toneAC utilizes timer 2, which solved my problems. So I guess I need to move to Timer2? Noob alert how do I know what timer I currently use?

It isn’t necessarily obvious. Some libraries use some timers. Without seeing your code it is hard to say.