The First Atmega8 Project

Introduction: The First Atmega8 Project

The eight LEDs will be flash by two groups alternately

Share

    Recommendations

    • Metalworking Contest

      Metalworking Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Tiny Home Contest

      Tiny Home Contest

    4 Discussions

    if this code doesn't work then:

    #include<avr/io.h>
    #include<util/delay.h>
    int main(void)
    {
    DDRB=0b11111111;
    DDRD=0b00000000;
    while(1);
    {
    PORTB=0b10000000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b01000000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00100000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00010000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00001000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000100;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000010;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000001;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b11111111;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    }
    }

    the code is :

    #include<avr/io.h>
    #include<util/delay.h>
    int main(void)
    {
    DDRB=0b11111111;
    DDRD=0b00000000;
    while(PIND=0b00000000);
    {
    PORTB=0b10000000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b01000000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00100000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00010000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00001000;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000100;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000010;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b00000001;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    PORTB=0b11111111;
    _delay_ms(500);
    _delay_ms(500);
    _delay_ms(500);

    }
    }