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

Please edit your post to add code tags. Select the code and use the "</>" editor button.

You generally should not do I/O of any kind in an interrupt routine, and especially not serial I/O, as it depends on interrupts.

Remove this line from the ISR:

Serial.println(num);
1 Like