Use PWM after Tone command

Hi All, here comes a Nooby question:

I noticed that use the "tone" command (which works fine) permanently disables PWM action.

Is there a way to set PWM, generate a tone (PWM stops), then stop the tone, and reinstate the PWM again?

I have a project where a LED is varied in strength using PWM, and a photo diode that picks up reflections. PWM is used to get the photodiode in the middle of measuring range before the measurement starts. The PWM value remains fixed after that.

I like to have a tone indicate the reflectivity. It is no problem to alternately use tone and switch on PWM, it does not have to be concurring.

Must be obvious - cannot find it.... TIA!

On a standard Arduino board I think tone only interferes with PMW on pins 3 and 11. Have you tried using the other PWM pins?

You rule! ....never occurred to me that PWM's were unequal. and yes, I was using 11. ::slight_smile:

Thanks a lot for the very fast reply!

No doubt this effect is clearly written down somewhere - but I managed to miss it. The "Reference" does not seem to mention this issue.

Great forum, this!

I have added a request in the bugs and suggestions thread to add this information to the tone reference page.