Electronic – Blink LED example does not work

atmegaavr

I'm trying to run standard Blink LED example on Atmega8A, but my LED doesn't blink.
Here is my circuit:
enter image description here

And here is my code:

#ifndef F_CPU
    #define 16000000UL
#endif // F_CPU

#include <avr/io.h>
#include <util/delay.h>

#define set_bit(target, num)    (   target |=   _BV(num))
#define clear_bit(target, num)  (   target &=   ~ _BV(num))
#define toggle_bit(target, num) (   target ^=   _BV(num))

#define DELAY_IN_MS 1000 /* 1 sec */


int main()
{
    set_bit(DDRD, PD7);
    set_bit(PORTD, PD7);
    while(1)
    {
        toggle_bit(PORTD, PD7);
        _delay_ms(DELAY_IN_MS);
    }

    return 0;
}

What's wrong?

Best Answer

It looks to me like you've got the Cathode of the LED wired to Vdd. That's the wrong way round, so you should turn around the LED. Or alternatively, wire the Cathode to GND instead of VDD. Also, it's poor practice not to include a resistor in the LED current path; 220 Ohms or so should be fine.

UPDATE:

It looks like you've got more problems than just that. Going by the pin-out posted by 'TMa', your Vcc,GND (p7,p8) look reversed. Also the GND on pin22 is unconnected. Usually all GNDs on an IC should be connected because they are internally connected via the substrate.