How to know if interrupt is triggered..


in below code run code in loop every time interrupt triggered..

how can done..??

code: [select]
const int ignitionpin = 2;
const int ignitioninterrupt = 0;
unsigned long interval;
unsigned long lastpulsetime = 0;


void setup()
{
  pinmode(2,input);
  pinmode(5,output);
  pinmode(6,output);
  pinmode(ignitionpin, input);
  attachinterrupt(ignitioninterrupt, &ignitionisr, falling);
 
}


void ignitionisr()
{
  unsigned long present = micros();
  interval = present - lastpulsetime;
  lastpulsetime = present;
 
}

void loop(){
 
    for(int i=1; i<= 12; i++){
    digitalwrite(5, high);digitalwrite(6, high);
    delaymicroseconds(50);
    digitalwrite(5, low);digitalwrite(6, low);
    delaymicroseconds((interval-3000)/60);
      for(int j=1 ;j<=4;j++)
        {digitalwrite(5, high);
        delaymicroseconds(50);
        digitalwrite(5, low);
        delaymicroseconds((interval-3000)/60);
     
    }
  }


}

first, take code out of loop() function, being called continuously arduino main() function.  if call interrupt handler, crash @ point.

regards,
ray l.


Arduino Forum > Using Arduino > Programming Questions > How to know if interrupt is triggered..


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code