Timer interrupt and PWM

Hello,
can I use analogWrite() function and Timer interrupt in the same code?
Thank you.

which Timer, arduino has more....

Easiest way is just to try -

What is your goal?

Mazen21:
can I use analogWrite() function and Timer interrupt in the same code?

Yes.

If you change the setup of the timer it can affect analogWrite, but you can add an interrupt handler for timers 1 and 2.

timer0 already has an interrupt handler that maintains the millis(), micros() and delay() time information, so its not wise to use this interrupt.

timer0 is used for PWM pins 5 and 6,
timer1 is used for PWM pins 9 and 10,
timer2 is used for PWM pins 11 and 3

(Arduino Mega's are different, note)

Thank you all for your answers.
I'm using arduino mega adk, and already using analogWrite() in pin 2 and 3.
I'm trying to do some code with a 5ms periode, The best way, I think, is using the timer interrupt, but I don't want to affect the analogWrite function.
Please if you have any links or answers send it to me.

Here is a link: