#ifndef F_CPU #define F_CPU 16000000UL #endif #include #include #include int main(void) { DDRB &= (uint8_t)~(1U << PB1); PORTB |= (1U << PB1); /* Internal pull-up, button to GND. */ PORTC &= (uint8_t)~(1U << PC0); DDRC |= (1U << PC0); uint8_t armed = 1; while (1) { if (armed && !(PINB & (1U << PB1))) { _delay_ms(100); if (!(PINB & (1U << PB1))) { PORTC ^= (1U << PC0); armed = 0; /* Holding the button cannot repeat. */ } } else if (!armed && (PINB & (1U << PB1))) { _delay_ms(100); if (PINB & (1U << PB1)) { armed = 1; } } } }