I'm using a Fio board and controlling 2 RGB LEDs with pwm on pins 3,5,6 and 9,10,11. I'm also using the Stepper library for a small stepper motor. The pwm for the LEDs is producing an audible hum in my project that I want to get rid of. Can I change the pwm frequency without affecting millis(), which the Stepper library uses for timing?
and connect a microphone to your PC sound card, you can use the Spectrum Analyzer to see what frequency the hum is at.
If it's ~490 Hz, that is likely the PWM. If it's something else, find the culprit.
Thanks for the input. When I turn the LEDs off, with AnalogWrite(0) on all LED pins, the noise goes away. So I'm pretty sure I'm hearing hum from the PWM. However, I don't hear it all the time. It changes with the colour changes. I've tuned some specific behaviour from the motors which I know will change if I alter the timers. I wanted to avoid retuning the motors but it sounds like I have no other option....
It's unusual to hear hum from LED controlled with PWM. I suspect that the PWM is affecting the supply voltage and that you are hearing the resulting hum from the stepper motor or some other component. How are the LEDs connected to the Arduino, in particular, do you have the right value series resistors?