#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
volatile uint8_t i;
int x;
ISR(PCINT0_vect)
{
x = 1;
}
ISR(PCINT1_vect)
{
x = 2;
}
int main (void)
{
DDRA = 0xff;
PORTB |= _BV(PB4); // pin PD.0 input pullup
PORTJ |= _BV(PJ1); // pin PD.1 input pullup
PCMSK0 |= (1<<PCINT4); // enable interrupt PCINT4;
PCMSK1 |= (1<<PCINT10); //enable interrupt PCINT10;
PCICR |= _BV (PCIE0)| _BV (PCIE1);
sei();
while (1) {
switch (x) {
case 0:
PORTA = 0XFF;
sei();
break;
case 1:
i++;
PORTA =~ i;
_delay_ms(500);
sei();
break;
case 2:
i--;
PORTA =~ i;
_delay_ms(500);
sei();
break;
}
}
}