Timer/Counter programming Arduino
It seems that the offending line is:

while ( (TIFR0 &amp; TOV0) == 0 )


TOV0 by itself equals 0, so the above loop will never end.

You should use:

 while ( (TIFR0 &amp; (1&lt;&lt;TOV0)) == 0 )


instead.