The code will not work "as written."
The first problem is surprising - the compile doesn't like the extra spaces in #include < inttypes.h >Perhaps this is a version or environment dependent thing? Or maybe the code got pretty-formatted for the web page without checking to make sure that didn't bother anything...
The second problem is that the arduino environment already defines an interrupt based on timer0 (this is what runs millis() and related timing functions. So trying to include another ISR for timer0 results in an error:
multiple definition of `__vector_16'
The arduino core does NOT use timer1 or timer2 interrupts, so you can in theory convert this to use one of them. Bringing us to your second question:
can I activate isr of timer 2 by ISR (TIMER1_OVF_vect);
I'm pretty sure that for timer 2 you'd need TIMER2_OVF_vect ![]()
Defining the vector does not actually "activate" the timer; it just provides code at the appropriate location to catch the timer interrupt once you have manually enabled it by writing the appropriate bits to the appropriate timer control and interrupt control registers...