To get a PWM signal with 5khz frequency using Arduino Uno

I recommend to study this excellent tutorial on timers: https://www.gammon.com.au/timers