#include <LiquidCrystal_I2C.h>
#include <IRremote.h>
#include <string.h>

#define I2C_ADDR    0x27
#define LCD_COLUMNS 16
#define LCD_LINES   2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
IRrecv receiver(2);
char* a = "";
char* b = "";
char* c = "";
int Cursor = 0;
int Line = 0;

void setup()
{
  lcd.init();
  lcd.backlight();
  //lcd.print("<press a button>");
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  receiver.enableIRIn(); // Start the receiver
}

void loop()
{
  // Checks received an IR signal
  if (receiver.decode()) {
    translateIR();
    c=strcat(b,a);
    lcd.print(b);
    receiver.resume();  // Receive the next value
  }
  
}

// void lcdPrint(char* text)
// {
//   lcd.clear();
//   lcd.setCursor(0, 0);
//   lcd.print(text);
//   delay(500);
// }

char translateIR()
{
  // Takes command based on IR code received
  switch (receiver.decodedIRData.command) {
    case 104:
      a = "0";
      break;
    case 48:
      a = "1";
      break;
    case 24:
      a = "2";
      break;
    case 122:
      a = "3";
      break;
    case 16:
      a = "4";
      break;
    case 56:
      a = "5";
      break;
    case 90:
      a = "6";
      break;
    case 66:
      a = "7";
      break;
    case 74:
      a = "8";
      break;
    case 82:
      a = "9";
      break;
    default:
      lcd.clear();
      lcd.print(receiver.decodedIRData.command);
      lcd.print(" other button");
  }
  }