#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// C++ code
//

void displayTemp();
int setTemp();
int setTime(int number);

const int input8 = 13;
const int input4 = 12;
const int input2 = 11;
const int input1 = 10;

int inputState8 = 0;
int inputState4 = 0;
int inputState2 = 0;
int inputState1 = 0;

int counter = 0;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
   lcd.begin(16,2);
  lcd.init();
  lcd.backlight();
  Serial.begin(9600);
  
  pinMode(input8,INPUT);
  pinMode(input4,INPUT);
  pinMode(input2,INPUT);
  pinMode(input1,INPUT);
}

void loop()
{
  inputState8 = digitalRead(input8);
  inputState4 = digitalRead(input4);
  inputState2 = digitalRead(input2);
  inputState1 = digitalRead(input1);

  int num;
  int time = 0;
    
       if(inputState8==LOW && inputState4==LOW && inputState2==LOW && inputState1==HIGH)
  {num = 0;}
  else if(inputState8==LOW && inputState4==LOW && inputState2==HIGH && inputState1==LOW)
  {num = 1;}
  else if(inputState8==LOW && inputState4==LOW && inputState2==HIGH && inputState1==HIGH)
  {num = 2;}
  else if(inputState8==LOW && inputState4==HIGH && inputState2==LOW && inputState1==LOW)
  {num = 3;}
  else if(inputState8==LOW && inputState4==HIGH && inputState2==LOW && inputState1==HIGH)
  {num = 4;}
  else if(inputState8==LOW && inputState4==HIGH && inputState2==HIGH && inputState1==LOW)
  {num = 5;}
  else if(inputState8==LOW && inputState4==HIGH && inputState2==HIGH && inputState1==HIGH)
  {num = 6;}
  else if(inputState8==HIGH && inputState4==LOW && inputState2==LOW && inputState1==LOW)
  {num = 7;}
  else if(inputState8==HIGH && inputState4==LOW && inputState2==LOW && inputState1==HIGH)
  {num = 8;}
  else if(inputState8==HIGH && inputState4==LOW && inputState2==HIGH && inputState1==LOW)
  {num = 9;}
  else if(inputState8==HIGH && inputState4==LOW && inputState2==HIGH && inputState1==HIGH)
  {num = 10;}//decimal
  else if(inputState8==HIGH && inputState4==HIGH && inputState2==LOW && inputState1==LOW)
  {num = 11;}//mode
  while (counter < 4){
  switch(num){
    case 11:
    counter=counter + 1;
    if(counter==1)
    {displayTemp();
    delay(1000);}
  
    else if(counter==2)
    {setTemp();
    delay(1000);}
  
    else if(counter==3)
    {setTime(num);
    delay(1000);}
  
    if(counter>3)
    {counter = 0;}
    break;
    case 1:
    lcd.print("Pressed 1");
    break;
  }
  Serial.print(counter);
  Serial.println();
}
}


void displayTemp()
 {lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Temp:");
  lcd.setCursor(0,1);
  lcd.print("Humid:");}
  
int setTemp()
 {lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Set Temp");}


int setTime(int number)
{
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("Set Time: ");

  if(number==1)
  {lcd.setCursor(1,1);
   lcd.print("Hour(s): ");
   lcd.print(1);
   number = 1;}
 }