#define set0(r,b) r&= ~(1<<b)
#define set1(r,b) r|= 1<<b
#define test(r,b) (r&(1<<b))

int cislo = 0;
uint32_t lastState;

void setup() {
  // put your setup code here, to run once:

  set0(DDRC,1);
  set1(PORTC,1);

  set0(DDRB,5);
  set1(PORTB,5);

  set0(DDRC,0);
  set1(PORTC,0);

  Serial.begin(9600);

  set1(PCICR,PCIE1);
  set1(SREG,7);
  set1(PCMSK1,PCINT9);

  set1(PCICR,PCIE0);
  set1(SREG,7);
  set1(PCMSK0,PCINT5);

  set1(PCICR,PCIE1);
  set1(SREG,7);
  set1(PCMSK1,PCINT8);

  lastState = PINC;
}

void loop() {
  // put your main code here, to run repeatedly:

}

ISR(PCINT0_vect)
{
  if(test(PINB,5) == 0)
  {
    cislo=0;
    Serial.println(cislo);
  }

}

ISR(PCINT1_vect)
{
    if(test(PINC,0) == 0 && test(lastState,0) != test(PINC,0))
    {
      cislo--;
      Serial.println(cislo);
    }

    if(test(PINC,1) == 0 && test(lastState,1) != test(PINC,1))
    {
      cislo++;
      Serial.println(cislo);
    }
  lastState = PINC;
}