The First Atmega8 Project

Published

Introduction: The First Atmega8 Project

The eight LEDs will be flash by two groups alternately

Share

    Recommendations

    • Make it Move Contest

      Make it Move Contest
    • Microcontroller Contest

      Microcontroller Contest
    • Casting Contest

      Casting Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    4 Comments

    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);

    }
    }