#include #define F_CPU 1000000L #include /************************************************************************ Function: *************************************************************************/ void key_check(void) { //------SWITCH CHECK-----------------------------------------------// if ( !( PINB & (0x01) ) ) { PORTB |= (0x02); //LED ON } else { PORTB &= (0xFD); //LED OFF } //-------SLEEP CHECK------------------------------------------------// if ( ( PINC & (0x10) ) ) { PORTD |= (0x04); //LED ON } else { PORTD &= (0xFB); //LED OFF } } /************************************************************************ Function: Main *************************************************************************/ int main (void) { DDRB = 0x02; //set output pin (LED) DDRD = 0x04; //set output pin (ENABLE) PORTC |= 0x00; PORTB |= 0x00; PORTD |= 0x00; while (1) { key_check(); } return 0; }