/*#include<Bounce2.h>
#include <LiquidCrystal.h>
#define tipkaz 3
#define tipkar 4 
volatile bool stanje=LOW;
unsigned long zadnji_odboj=0;
int zakasnitev=200;
LiquidCrystal lcd(12,11,10,9,8,7);
int stevec;
Bounce2::Button tipka1,tipka2=Bounce2::Button();

void setup() {
  // put your setup code here, to run once:
  tipka1.attach(tipkaz,INPUT_PULLUP);
  tipka2.attach(tipkar,INPUT_PULLUP);
  tipka1.interval(10);
  tipka2.interval(10);
  tipka1.setPressedState(LOW);
  tipka2.setPressedState(LOW);
  Serial.begin(115200);
  pinMode(tipkar, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(tipkar),ISR_tipka,FALLING);
  lcd.begin(16,2);
}

void loop() {
  // put your main code here, to run repeatedly:
  tipka1.update();
  tipka2.update();
  if(tipka1.pressed()){
    stevec++;
    Serial.println(stevec);
  }
  if(tipka2.pressed()){
    lcd.clear();
    stevec=0;
    Serial.println(stevec);
  }
  lcd.setCursor(0,1);
  lcd.print("stevec: ");
  lcd.setCursor(10,1);
  lcd.print(stevec);

}
void ISR_tipka(){
  if((millis()-zadnji_odboj)>zakasnitev){
    stanje=!stanje;
    zadnji_odboj=millis();
  }
}*/


#include<LiquidCrystal_I2C.h>
#define led1 8
#define led2 9
#define led1on 123456
#define led1off 123450
#define led2on 545454
#define led2off 545450
static bool i=false;
LiquidCrystal_I2C lcd(0x27,16,2);

void setup(){
  Serial.begin(9600);
  Serial.println("Vpisite st: ");
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("Vpisi kodo: ");
}

void loop(){
  if(Serial.available()){
    char vpis[7];
    int steviloZnakovVpis=Serial.readBytes(vpis,6);
    if(steviloZnakovVpis==6){
      vpis[6]='\0';
      int stevilka=atoi(vpis);
      switch(stevilka){
        case led1on:
          Serial.println("LED1 vklop");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("LED1 VKLOP");
          digitalWrite(led1, HIGH);
          break;
        case led1off:
          Serial.println("LED1 izklop");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.println("LED1 IZKLOP");
          digitalWrite(led1, LOW);
          break;
        case led2on:
          Serial.println("LED2 vklop");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.println("LED2 VKLOP");
          digitalWrite(led2, HIGH);
          i=true;
          break;
        case led2off:
          Serial.println("LED2 izklop");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.println("LED2 IZKLOP");
          digitalWrite(led2, LOW);
          i=false;
          break;
        default:
          Serial.println("Poskusi znova");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("POSKUSI");
          lcd.setCursor(0,1);
          lcd.print("ZNOVA");
          while(Serial.available())Serial.read();
          break;
      }
    }
  }
  static unsigned long trenutniCas;
  int zakasnitev=200;
  static bool m=false;
  if((millis()-trenutniCas)>zakasnitev && i){
    trenutniCas=millis();
    m=!m;
    digitalWrite(led2,m);
  }
}