avr/led2/led2.c
2021-05-16 16:53:56 -05:00

32 lines
626 B
C

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