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();
}
__```**__
