#include <avr/io.h>
#include <avr/interrupt.h>
ISR(PCINT2_vect) {
//inputs are active low
uint8_t pd = ~PIND;
if (pd & 0x80)//we need to determine which pin generated interrupt
PORTB |= 1 << PB1;
else if (pd & 0x40)
PORTB &= ~(1 << PB1);
}
void setup()
{
DDRD &= ~((1 << PD7) | (1 << PD6)) ;//port D as input
PORTD = (1 << PD7) | (1 << PD6);//use pull up resistors PORTD6 and 7
DDRB= 1 << PB1;//output port bit
// Enable pin change interrupts
PCICR = 1 << PCIE2;//enable pin change interrupt bank 2
PCMSK2 = (1 << PCINT22) | (1 << PCINT23);//enable pin change interrupt on PCINT22 PCINT23
sei();// Set global interrupt flag
}
int main()
{
init();
setup();
while(true);
}