If a 5V fan is used, the adjustments to the 12V are omitted, which simplifies the circuit. Only the pull ups against 5V and a diode are needed. I use cheap Arduino Pro Micro (ATmega32U4), from China. The 25kHz I create after an example by Edgar Bonet. He has released the short program on StackExchange in response.
Set PWM frequency to 25 kHz It’s the code in the second response.
// PWM output @ 25 kHz, only on pins 9 and 10.
// Output value should be between 0 and 320, inclusive.
void analogWrite25k(int pin, int value)
The photo shows a test setup with a Leonardo powered via USB from the Raspberry 3 B+, which is also to be cooled. The housing is made of aluminium and also serves as a passive cooler, which is sufficient up to 3 B, but no longer for the 3 B+.