/* * Vaja6.c * * Created: 17.04.2013 8:03:55 * Author: maticpi */ #include #include #include #include void Init(); int main(void) { Init(); sleep_enable(); sei(); while(1) { PORTB &= ~0x80; sleep_cpu(); PORTB |= 0x80; } } ISR(INT0_vect) { PORTB^=0x01; } int cnt; ISR(TIMER0_COMPA_vect) { PORTB |= 0x80; if (cnt >= 500) { cnt = 0; PORTB ^= 0x02; } cnt++; } void Init() { //IO port PORTA=0x08; //0000 1000 PORTB=0x00; //0000 0000 PORTC=0x3E; //0011 1110 PORTD=0x7D; //0111 1101 //1-output, 0-input DDRA=0xF0; //1111 0000 DDRB=0xFF; //1111 1111 DDRC=0xC1; //1100 0001 DDRD=0x82; //1000 0010 //external interrupt 0 EICRA=(1<