Help understand a simple C code for an atmega16 project
I can't really answer many of the specific questions about what the pieces of your code do, but I'll explain the bit shifting (the 1 &lt;&lt; n lines).

You can represent 1 as the 8 bit binary number 0000 0001. The &lt;&lt; operator takes all of the bits and moves them 1 spots to the right, throwing out the MSB and putting a 0 on the LSB. That means that 1 &lt;&lt; 3 = 0000 1000. If you label the bits 0 through 7, we now have a number where the only high bit is in position 3.

This is useful for working with the 8 separate pins in your PORTA, PORTB, etc registers. For example, if you want to set pins 0, 2, and 5 high, you want to write

PORTD = 0010 0101

but it's much easier to quickly read and edit a line that uses the OR operator |, making your code look like

PORTD = 1&lt;&lt;5 | 1&lt;&lt;2 | 1&lt;&lt;0

which clearly says "set bits 0, 2, and 5 high".

(PS: fix your indenting! yuck!)