INTERRUPT – ARM

Photo of author

By Jackson Taylor

int a=0;
void setup()
{
  pinMode(PF_2, OUTPUT); //for blue led
  pinMode(PF_3, OUTPUT); //for green led
  pinMode(PUSH2, INPUT_PULLUP);
  attachInterrupt(PF_0, blinky, FALLING); // Interrupt is fired whenever button is pressed
                                         //  Here Blinky is interrupt service function
}
void loop()  //normally this loop plays 
{
  digitalWrite(PF_2, 1); //blue LED starts ON
  delay(1000);
  digitalWrite(PF_2, 0); //blue LED starts Off
  delay(1000);
}
void blinky() //this loop will excute when interrupt occur
{
  a = !a;
 digitalWrite(PF_3,a);  // output of green led will negate
}