const int interruptPin2 = 2;
volatile bool isButtonPressed2 = false;
//
const int interruptPin3 = 3;
volatile bool isButtonPressed3 = false;
void setup()
{
Serial.begin(9600);
pinMode(interruptPin2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin2), button_pressed2, LOW);//pin#, ISR, Mode
Serial.println("Pin 2 set up is done");
//
pinMode(interruptPin3, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin3), button_pressed3, LOW);//pin#, ISR, Mode
Serial.println("Pin 3 set up is done");
pinMode(interruptPin2, OUTPUT);
pinMode(3, OUTPUT);
}
//
void loop()
{
//Serial.println("In main loop");
Serial.println("Button 2 Pressed!");
if(isButtonPressed2){
isButtonPressed2 = false;
}
//
if(isButtonPressed3){
Serial.println("Button 3 Pressed!");
isButtonPressed3 = false;
}
}
//ISR for pin 2
void button_pressed2()
{
isButtonPressed2 = true;
}
//ISR for pin 3
void button_pressed3()
{
isButtonPressed3 = true;
}
//
void LED()
{
digitalWrite(3, HIGH); // turn the LED on (High voltage level)
delay(1000); // wait for one second
digitalWrite(3, LOW); // turn the LED off (Low voltage level)
delay(1000); // wait for a second
}