21 lines
354 B
C
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);
|
|
}
|
|
}
|