Arduino PWM output frequencies and Tone command
April 11, 2010
I've been playing with a new oscilloscope Dagu bought after the old one died. I decided to check out the Arduino PWM outputs because I'm using an Arduino in my new speed controller and wanted to check if there were any differences as the brake function requires two PWM outputs to be be in sync so that both input are high or low at the same time.
The PWM outputs on pins 5 and 6 share a timer with timing functions such as millis() and delay() run at about 976Hz while PWM outputs on pins 3,9,10 and 11 run at about 488Hz.
Fortunately I was already avoiding the PWM pins 5 and 6 because of their interaction with the time functions. All other PWM outputs sync nicely when set to the same dutycycle, good news for my speed controller :D
After some recent problems I have also discovered that the tone command kills PWM on pins 3 and 11. This is because the tone command uses the same timer. Unfortunately the noTone command does not reset the timer back to default settings.
This is unfortunate because I need all the PWM outputs for a robot I'm building and I also wanted to play tunes. Does anyone know how to undo the changes made by the tone command to reactivate the PWM command on those pins?