getting different value for the same key of remote control

I am using ESP32 WROOM-32 U. I am trying to read signal value transmitted by remote control by pressing a key. Every time 2-4 data get added to the previous value while pressing the same key. Every time some other values get added in previous array values of arr and arr1 value. This is the same for other remote also. Every time the number of values gets added in the previous array is different. I want to do this without using any library.

void setup() {
  Serial.begin(115200);
  pinMode (ir_in, INPUT);
}

void loop()
{
  // put your main code here, to run repeatedly:
  value = digitalRead(ir_in);
  if (value == 0)
  {
    flag = 1;
    while ((digitalRead(ir_in) == 0) && (flag == 1))
    {
      count++;
      delayMicroseconds(1);


    }
    arr[no_pulse++] = count;
    count = 0;
    while ((digitalRead(ir_in) == 1) && (flag == 1))
    {
      count++;
      delayMicroseconds(1);

    }
    arr1[no_pulse1++] = count;

    count = 0;
    flag = 0;
    for (i = 0; i <= no_pulse; i++)
    {
      Serial.print("arr-");
      Serial.println(arr[i]);
    }

    for (i = 0; i <= no_pulse1; i++)
    {
      Serial.print("arr1-");
      Serial.println(arr1[i]);
    }
  }

}

This is the first data of arr and arr1:

arr-4630
arr-256
arr-243
arr-301
arr-302
arr-305
arr-191
arr-306
arr-4635
arr-0
arr1-2230
arr1-266
arr1-269
arr1-271
arr1-831
arr1-831
arr1-834
arr1-831
arr1-1103
arr1-0

2nd data by pressing same key( 5 data added in arr and same 5 data in arr1):

arr-4630
arr-256
arr-243
arr-301
arr-302
arr-305
arr-191
arr-306
arr-4635
arr-4623
arr-176
arr-304
arr-53
arr-4635
arr-0
arr1-2230
arr1-266
arr1-269
arr1-271
arr1-831
arr1-831
arr1-834
arr1-831
arr1-1103
arr1-2240
arr1-272
arr1-833
arr1-830
arr1-1106
arr1-0

The code that you posted does not compile. Did you forget to copy the global variable declarations ?

Do the values of no_pulse and no_pulse1 keep getting larger for ever ?

Hi UKHeliBob,
Thanks for the reply. Yes, i forgot to copy those variables. Here i am posting that code again. No,no_pulse and no_pulse1 keep getting larger. And also tell me how can i convert arr and arry1 value to HEX so i can store those values in HEX format.

int ir_in = 15, value, arr[500], arr1[500], i;
unsigned int count, flag = 0, no_pulse = 0, no_pulse1 = 0;

void setup() {
  Serial.begin(115200);
  pinMode (ir_in, INPUT);
}

void loop()
{
  // put your main code here, to run repeatedly:
  value = digitalRead(ir_in);
  if (value == 0)
  {
    flag = 1;
    while ((digitalRead(ir_in) == 0) && (flag == 1))
    {
     
      delayMicroseconds(1);
       count++;

    }
    arr[no_pulse++] = count;
    count = 0;
    while ((digitalRead(ir_in) == 1) && (flag == 1))
    {
      
      delayMicroseconds(1);
      count++;
    }
    arr1[no_pulse1++] = count;

    count = 0;
    flag = 0;
    for (i = 0; i <= no_pulse; i++)
    {
      Serial.print("arr-");
      Serial.println(arr[i]);
    }

    for (i = 0; i <= no_pulse1; i++)
    {
      Serial.print("arr1-");
      Serial.println(arr1[i]);
    }
  }

}

Below is the snippet of my pic controller code to measure remote control key value in hex and stores it into an array using a timer.:

   LED1 = 0;
     TON_bit = 0;
     delay_ms(100);
     TON_bit = 1;
     while((no_pulse < total_pulse)&& (time_over == 0))
      {
        while((IR_IN == 1) && (time_over == 0) );
        TON_bit = 0;
        TON_bit = 1;
        TMR1 = 0;
        while((IR_IN == 0)&& (time_over ==0));
         irdata[no_pulse++] = (TMR1>>8)&0xff;
         irdata[no_pulse++] = TMR1&0xff;
        TON_bit = 0;
        TON_bit = 1;
        TMR1 = 0;
        while((IR_IN == 1)&& (time_over ==0));
         irdata[no_pulse++] = (TMR1>>8)&0xff;
         irdata[no_pulse++] = TMR1&0xff;
      }
       LED1 = 1;
       delay_ms(2000);

no_pulse and no_pulse1 keep getting larger

What is going to happen when they reach a value of 500 and the program starts to write outside of the memory allocated to the arrays ?

how can i convert arr and arry1 value to HEX so i can store those values in HEX format.

Where exactly do you want to store them and why ?

UKHeliBob:
What is going to happen when they reach a value of 500 and the program starts to write outside of the memory allocated to the arrays ?

I do not know whether i am getting actual signal value or not or i am on the right way or wrong. But when i tried to read key-value i have not reached up to that maximum array limit yet. Even when i took 2000 value of both array there was no change in output value.I want to do this without using ir or any library.

UKHeliBob:
Where exactly do you want to store them and why ?

I am trying to read remote control key value and that value i want to store in an array to store in eeprom and then use that value for my blaster circuit.

Below is the snippet of my pic controller code which is i am trying convert for esp32 wroom to measure remote control key value in hex and stores it into an array using a timer.:

LED1 = 0;
    TON_bit = 0;
    delay_ms(100);
    TON_bit = 1;
    while((no_pulse < total_pulse)&& (time_over == 0))
     {
       while((IR_IN == 1) && (time_over == 0) );
       TON_bit = 0;
       TON_bit = 1;
       TMR1 = 0;
       while((IR_IN == 0)&& (time_over ==0));
        irdata[no_pulse++] = (TMR1>>8)&0xff;
        irdata[no_pulse++] = TMR1&0xff;
       TON_bit = 0;
       TON_bit = 1;
       TMR1 = 0;
       while((IR_IN == 1)&& (time_over ==0));
        irdata[no_pulse++] = (TMR1>>8)&0xff;
        irdata[no_pulse++] = TMR1&0xff;
     }
      LED1 = 1;
      delay_ms(2000);

'''