#define SET1(r,b) r|=1<<b
#define SET0(r,b) r&=~(1<<b)
#define TEST(r,b) (r&(1<<b))
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16,2);
int num = 0;
bool activeLCD;
bool vosiel;
bool vosiel1;
void setup(){
Serial.begin(9600);
lcd.init();
lcd.backlight();
SET1(PORTB, 0);
SET1(PORTB, 1);
SET1(PCMSK0, PCINT0);
SET1(PCMSK0, PCINT1);
SET1(PCICR, PCIE0);
SET1(SREG, 7);
vosiel = TEST(PINB, 0);
vosiel1 = TEST(PINB, 1);
lcd.print("Zadaj cislo!");
}
void loop(){
if(Serial.available()){
//String pismeno = Serial.readStringUntil('+');
num = Serial.parseInt();
Serial.println("Zadal si: "+String(num));
lcd.clear();
lcd.print(num);
}
if(activeLCD == true){
activeLCD = false;
lcd.clear();
lcd.print(num);
}
vosiel = TEST(PINB, 0);
vosiel1 = TEST(PINB, 1);
}
ISR(PCINT0_vect){
if(TEST(PINB, 0) == 0 && vosiel != 0){
num++;
activeLCD = true;
}
if(TEST(PINB, 1) == 0 && vosiel1 != 0){
num--;
activeLCD = true;
}
}