2021-05-15 16:20:06 +00:00
|
|
|
#include <avr/io.h>
|
|
|
|
#include <util/delay.h>
|
|
|
|
#include <limits.h>
|
|
|
|
|
2021-05-16 21:53:56 +00:00
|
|
|
#define DELAY 75
|
|
|
|
#define LEN sizeof(PORTB) * CHAR_BIT - 1
|
|
|
|
#define LED_DDR DDRB
|
|
|
|
#define LED_PORT PORTB
|
2021-05-15 16:20:06 +00:00
|
|
|
|
|
|
|
int main(void) {
|
2021-05-16 21:53:56 +00:00
|
|
|
uint8_t i;
|
2021-05-15 16:20:06 +00:00
|
|
|
|
2021-05-16 21:53:56 +00:00
|
|
|
LED_DDR = 0xff;
|
2021-05-15 16:20:06 +00:00
|
|
|
|
|
|
|
for (;;) {
|
2021-05-16 21:53:56 +00:00
|
|
|
for (i = 0; i < LEN; i++) {
|
2021-05-15 16:20:06 +00:00
|
|
|
_delay_ms(DELAY);
|
2021-05-16 21:53:56 +00:00
|
|
|
LED_PORT = (1 << i);
|
|
|
|
// LED_PORT = ~(1 << i);
|
|
|
|
// LED_PORT |= (1 << i);
|
2021-05-15 16:20:06 +00:00
|
|
|
}
|
2021-05-16 21:53:56 +00:00
|
|
|
for (i = LEN; i > 0; i--) {
|
2021-05-15 16:20:06 +00:00
|
|
|
_delay_ms(DELAY);
|
2021-05-16 21:53:56 +00:00
|
|
|
LED_PORT = (1 << i);
|
|
|
|
// LED_PORT = ~(1 << i);
|
|
|
|
// LED_PORT |= (1 << i);
|
2021-05-15 16:20:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|