Code to obtain PWM output
Read the datasheet.
Figure out which pen mode works for you and which prescaler and top you need.
Set timer1 to that mode.


After that all you need is to load the duty cycle register with the desired value.

For your application leave the top value alone.

Your code is far from that.