High Frequency pwm with millis

I was attempting to crontrol a fan using PWM and a tip122 but the default PWM frequency is causing my fan to make a irritating noise.

I've read that you can change the timer so the PWM frequency is higher. But also that this can skrew up millis and delay.

Millis and delay uses timer 0 but pin 3 uses TCCR2B.

TCCR2B = TCCR2B & 0b11111000 | 0x01;

This will output a PWM at 31kHz.

If I change TCCR2B will millis and delay still work correctly?

If I change TCCR2B will millis and delay still work correctly?

Yes :)

excellent!

Thank you Grumpy

This works as a charm.

Just to check are there other things running on Timer2 (TCCR2B)?

are there other things running on Timer2

No only the PWM.

On the Uno, pins 5,6 are timer0 (same as delay(), millis(), micros()), pins 9,10 are timer1 pins 11, 3 are timer2.