Issues with attachInterrupt

Hello everybody
I am new to Arduino, I have been trying to use attachInterrup function, in order to read IR raw data, it worked well, however after some additional trials, the function stopped working and I did not get anything in the serial Window, can anybody tell me what am i doing wrong here? Please see the code below.

const int IRPin = 2;
const int numberOfEntries = 35; //(69 for Change), (35 for falling)

volatile unsigned long microseconds;
volatile byte index = 0;
volatile unsigned long results[numberOfEntries];
unsigned long address = 0x00;
long command = 0x00;

void setup()
{
detachInterrupt(0);
pinMode(IRPin, INPUT);
Serial.begin(9600);
attachInterrupt(0,measure,CHANGE);
results[0] = 0;
}

void loop()
{

if(index >= numberOfEntries)
{
for (int b=2;b<=17;b++)
{

if (results__>=1100 & results**<=1500)__
__
{__
__
address = (address<<1);__
__
address |= (0x00);__
__
}__
else if(results__>=2100 & results<=2500)
{
address =(address<<1);
address |=(0x01);
}
}
for (int c=18;c<=33;c++)
{
if (results**

```c__

**>=1100 & results[c]<=1500)
      {
        command = (command<<1);
        command |= (0x00);
      }
      else if(results[c]>=2100 & results[c]<=2500)
      {
      command =(command<<1);
      command |=(0x01);
      }
    }
     
    Serial.println(address,HEX);
    Serial.println(command,HEX);
    Serial.println("Durations in microseconds are: ");
    for (byte i = 0; i< numberOfEntries;i++)
    {
      Serial.println(results[i]);
    }
   
 
  }
 
    while(1)
   
    ;
   
 
  delay(500);
}

void measure()
{
  if (index < numberOfEntries)
  {
    if(index>0)
    {
      results[index] = micros()-microseconds;
    }
    index = index + 1;
  }
  microseconds = micros();
}

__```**__

Can you please add code tags to your code:

maov98:
Hello everybody
I am new to Arduino, I have been trying to use attachInterrup function, in order to read IR raw data, it worked well, however after some additional trials, the function stopped working and I did not get anything in the serial Window, can anybody tell me what am i doing wrong here?

Is this intentional:

    while(1)
   
    ;

Saludos

Just try this sketch

const int IRPin = 2;
const int numberOfEntries = 35;  //(69 for Change), (35 for falling)


volatile unsigned long microseconds;
volatile byte index = 0;
volatile unsigned long results[numberOfEntries];
unsigned long address = 0x00;
long command = 0x00;

void setup()
{
  detachInterrupt(0);
  pinMode(IRPin, INPUT);
  Serial.begin(9600);
  attachInterrupt(0,measure,CHANGE);
  results[0] = 0;
}

void loop()
{

  if(index >= numberOfEntries)
  {
    for (int b=2;b<=17;b++)
    {

      if (results[b]>=1100 && results[b]<=1500)
      {
        address = (address<<1);
        address |= (0x00);
      }
      else if(results[b]>=2100 & results[b]<=2500)
      {
        address =(address<<1);
        address |=(0x01);
      }
    }
    for (int c=18;c<=33;c++)
    {
      if (results[c]>=1100 && results[c]<=1500)
      {
        command = (command<<1);
        command |= (0x00);
      }
      else if(results[c]>=2100 && results[c]<=2500)
      {
        command =(command<<1);
        command |=(0x01);
      } 
    }

    Serial.println(address,HEX);
    Serial.println(command,HEX);
    Serial.println("Durations in microseconds are: ");
    for (byte i = 0; i< numberOfEntries;i++)
    {
      Serial.println(results[i]);
    }


  }


  delay(500);
}

void measure()
{
  if (index < numberOfEntries && index>0)
  {
    results[index] = micros()-microseconds;
  }
  index = index + 1;
  microseconds = micros();
}

max_saeta:
Saludos

Realice unas correciones al sketch publicado, dices que funciona pero no estoy seguro que lo hiciera con el codigo publicado.

ENGLISH please, in the English language section.

...R

... the function stopped working ...

  while(1)

    ;

As expected.