Being picky again, and I am sure I am stating something that has been said before. However in my opinion this
PORTB &= (128 + 64 + 32 + 16 + 8 + 4 + 1); // this sets PB1 (the pwm output) to 0 at startup. Notice '2' is missing!
Is better written as
PORTB &= 0xFD; // this clears PB1 (the pwm output) at startup.
I appreciate that hexadecimal may be unfamiliar at first, believe me if you are going to be programming regularly it is highly advisable to become familiar with HEX.
Also in programming speak you don't "set" something to "0".
|