28 lines
444 B
C
28 lines
444 B
C
#include <avr/io.h>
|
|
#include <util/delay.h>
|
|
#include <limits.h>
|
|
|
|
#define DELAY 50
|
|
#define BITS sizeof(PORTB) * CHAR_BIT - 1
|
|
|
|
int main(void) {
|
|
int i;
|
|
|
|
DDRB = 0xff;
|
|
|
|
PORTB = 1;
|
|
|
|
for (;;) {
|
|
for (i = 0; i < BITS; i++) {
|
|
_delay_ms(DELAY);
|
|
PORTB = PORTB << 1;
|
|
}
|
|
for (i = BITS; i > 0; i--) {
|
|
_delay_ms(DELAY);
|
|
PORTB = PORTB >> 1;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|