Each time you write to PORTx, you need to set the status of all 8 bits. When you do this:
PORTD = (1 << PD2);
PORTD = (0 << PD2);
... what you're actually doing is this:
Set pin D2 on, and all other pins on PORTD off;
Set pin D2 off, and all other pins on PORTD off;
There are several things wrong with this:
First, setting PORTD with an equal sign sets the state of all 8 pins at once. However, your code is only explicitly setting / clearing one bit. The point you're missing is that changes are absolute, not cumulative, so you can't set PORTD with one pin's value without implicitly setting the state of the other 7 pins to LOW.
This is why you need to use bitwise operators, to make changes to a single bit while preserving the status of all the others:
PORTD = (1 << PD2); // This means set PORTD to 0000 0100
PORTD = (0 << PD2); // This means set PORTD to 0000 0000
// This means set PORTD to PORTD's existing value, combined with 0000 0100
// In other words, turn on bit 2
PORTD |= (1 << PD2);
// This means set PORTD to PORTD's existing value, with a mask of 1111 1011
// In other words, clear bit 2
PORTD &= ~(1 << PD2);
You need to look up bitwise operators and logic truth tables to really understand what this does, but to sum up:
0 | 0 = 0
0 | 1 = 1
1 | 0 = 1
1 | 1 = 1
0 & 0 = 0
0 & 1 = 0
1 & 0 = 0
1 & 1 = 1
~0 = 1
~1 = 0
(1 << PD2) = 0000 0100
(0 << PD2) = 0000 0000
~(1 << PD2) = 1111 1011
~(0 << PD2) = 1111 1111
Therefore:
0000 0000 | 0000 0100 = 0000 0100 // PORTD |= (1 << PD2)
0000 0100 & 1111 1011 = 0000 0000 // PORTD &= ~(1 << PD2)
Now, your code did in fact light up PD2... but only for one instruction cycle, before all bits were turned off in the next instruction. So essentially, you will never see D2 light up.