#include <Arduino.h>
// leds and switches
const byte led_pin2 = 13;
const byte led_pin1 =11;
const byte button_pin2= 7;
//const byte button_pin1 =2;
// boolean for inputs states
//volatile bool D2 =LOW;
//volatile bool D7 =LOW;
void setup() {
pinMode(led_pin2, OUTPUT);
pinMode(led_pin1, OUTPUT);
//pinMode(button_pin1, INPUT_PULLUP);
pinMode(button_pin2, INPUT_PULLUP);
// Enable PCICR2 bit3 = 1 Port D
PCICR |= 0x04;
//Enable PCINT18 & PCINT23 (Pins D2 & D7)
PCMSK2 |= 0x80;
}
void loop() {
for(int y=0;y<4;y++){
digitalWrite(led_pin1, HIGH);
delay(500);
digitalWrite(led_pin1, LOW);
delay(500);
}
}
ISR(PCINT2_vect){
if(digitalRead(button_pin2)==0){
digitalWrite(led_pin2, HIGH);
}
else{
digitalWrite(led_pin2, LOW);
}
}