Problem with LCD calculator with IR remote!

Hello guys, i am currently working on a IR remote controlled LCD calculator but i am having some code problems. Can you guys help me to get rid of that?

Example calculation; 00132+01256=?

But code seems fine but when i press sum button it gives nothing to me it just waits and waits. What's wrong with that? Thank you :slight_smile:

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

LiquidCrystal_I2C  lcd(0x27,16,2);

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  lcd.init();
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  int i=0,c;
  int x[10];
  char y;
  int number,op;
  lcd.backlight();
  
  if (irrecv.decode(&results)) {
    if(results.value==16769055 || results.value==16754775){
      if(results.value==16769055){
      y='-';
      lcd.print("-");
      Serial.print("-");
      }
      if(results.value==16754775){
      y='+';
      lcd.print("+");
      Serial.print("-");
      }
      }
      else{
    switch(results.value){
      
      case 16738455:
      x[i]=0;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16724175:
      x[i]=1;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16718055:
      x[i]=2;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16743045:
      x[i]=3;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16716015:
      x[i]=4;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16726215:
      x[i]=5;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16734885:
      x[i]=6;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16728765:
      x[i]=7;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16730805:
      x[i]=8;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 16732845:
      x[i]=9;
      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;
      break;
      
      case 0xFF906F:
      lcd.clear();
      break;
      
      case 16756815:
        lcd.print("=");
        Serial.print("=");
      if(y=='-'){
        c=(10000*x[0]+1000*x[1]+100*x[2]+10*x[3]+x[4])-(10000*x[5]+1000*x[6]+100*x[7]+10*x[8]+x[9]);
        lcd.print(c);
        Serial.print(c);
      }
      if(y=='+'){
        c=(10000*x[0]+1000*x[1]+100*x[2]+10*x[3]+x[4])+(10000*x[5]+1000*x[6]+100*x[7]+10*x[8]+x[9]);
        lcd.print(c);
        Serial.print(c);
    }
        break;
      
    }
    
  }
  delay(500);
    irrecv.resume();
  }
  
  
}
    if(results.value==16769055 || results.value==16754775){
      if(results.value==16769055){

If you are going to take one action if the value is A and another if the value is B, it makes no sense to test for the value being A or B first. Get rid of the outer if teat and learn to use else if statements.

Get rid of the magic numbers. Use #define statements to give the magic numbers names that mean something.

Put every { on a new line. Use Tools + Auto Format to fix the indenting. Your code is too hard to read as it is.

      Serial.print(number);
      lcd.print(number);
      Serial.print(x[i]);
      i++;

Pay some attention. If it not necessary to do this in every case. Set a flag, and do it once, after the switch statement, if the flag is true.

The x array should be global or static. Getting a new array on each pass through loop, as you are doing now, doesn't do much for persistence of values.

Ditto for i, c, y, number, and op. AND loose the one letter names. There is an implied relationship when you use names like x and y that is not true in your code. Use two arrays for the two numbers.

Hey man, Im starting with Arduino and one of the projects of the class is to make a calculator with IR Remote, did you resolve the issue with your code? if yes, could you please share it? many thanks.

if yes, could you please share it?

I believe you said:

one of the projects of the class is to make a calculator with IR Remote

I'm pretty sure that your instructor did NOT say "Search the web for some code someone else wrote so you can claim it as your own".