day00/ex02/main.c
2026-04-13 14:19:41 +02:00

21 lines
354 B
C

#include <avr/io.h>
#include <util/delay.h>
#include <stdbool.h>
#define LED_PORT PORTB0
#define BTN_PORT PIND2
int main(void) {
// set pin to output
DDRB |= (_BV(LED_PORT));
while (true) {
bool cur = (PIND & _BV(BTN_PORT));
if (!cur)
PORTB |= (_BV(LED_PORT));
else
PORTB &= ~(_BV(LED_PORT));
_delay_ms(20.f);
}
}