Introduction: The First Atmega8 Project

The eight LEDs will be flash by two groups alternately

Comments

author
arhamm (author)2015-06-21

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

}
}

author
arhamm (author)2015-06-21

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

}
}

author
arhamm (author)2015-06-21

author
Computothought (author)2012-01-29

code?

About This Instructable

5,420views

3favorites

License:

More by hongyeana:The first Atmega8 Project
Add instructable to: