#include #include #include #define DELAY 75 #define LEN sizeof(PORTB) * CHAR_BIT #define LED_DDR DDRB #define LED_PORT PORTB void _delay_s(double __s) { int i; for (i = 0; i < __s; i++) _delay_ms(1000); } int main(void) { uint8_t i; LED_DDR = 0xff; for (;;) { for (i = 0; i < LEN; i++) { _delay_ms(DELAY); LED_PORT |= (1 << i); } for (i = 0; i < LEN; i++) { _delay_ms(DELAY); LED_PORT &= ~(1 << i); } _delay_s(1); for (i = LEN; i < 255; i--) { _delay_ms(DELAY); LED_PORT |= (1 << i); } for (i = LEN; i < 255; i--) { _delay_ms(DELAY); LED_PORT &= ~(1 << i); } _delay_s(1); } return 0; }