Measure PWM Duty Cycle on a Specific PIN (Arduino Mega )

Crap code. You should not be printing from inside an interrupt service routine.

Now if you could answer the questions in reply #1 then maybe we could get somewhere. There is something about the way you are asking the question that suggests you want to measure the duty cycle of PWM being generated from one of the Arduino’s pins, which is silly as you already know the duty cycle because you set it in the first place.