Smoothing PWM for electromagnet

What was wrong with the default PWM frequency (pin dependent) of the Arduino.
If it squeals, then you pick a higher frequency, not a lower one.

Analogue/voltage is usually not an option, because that heats up the mosfet.
Leo..