You are on page 1of 1

int b=1;

void setup()
{
pinMode(9, OUTPUT); //Configure pin 9 as output
pinMode(2, INPUT_PULLUP); //Configure internal pull-up
resistor for pin 2
attachInterrupt(digitalPinToInterrupt(2), stop, CHANGE);
//Make pin 2 as an external interrupt, ISR function is stop(), Mode of
operation is change
}
void loop()
{
if(b==1){ //If a==1 normal mode of operation occurs
digitalWrite(9,HIGH); //LED blinks for every 2 sec
delay(2000);
digitalWrite(9,LOW);
delay(2000);
}
}
void stop()
{
digitalWrite(9,HIGH); //If interrupt occurs LED goes to
continuous ON state
b=2;
}

You might also like