byte status = 0;
void setup() {
attachInterrupt(0, detect, CHANGE);
attachInterrupt(1, detect2, CHANGE);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
Serial.begin(9600);
}
void detect() {
if((PIND & 0b00000100) && !(PIND & 0b00001000)) {
status = 1;
}
if(!(PIND & 0b00000100) && !(PIND & 0b00001000)) {
status = 2;
}
if(!(PIND & 0b00000100) && (PIND & 0b00001000)) {
status = 3;
}
if((PIND & 0b00000100) && (PIND & 0b00001000)) {
status = 4;
}
}
void detect2() {
if((PIND & 0b00000100) && !(PIND & 0b00001000)) {
status = 1;
}
if(!(PIND & 0b00000100) && !(PIND & 0b00001000)) {
status = 2;
}
if(!(PIND & 0b00000100) && (PIND & 0b00001000)) {
status = 3;
}
if((PIND & 0b00000100) && (PIND & 0b00001000)) {
status = 4;
}
}
void loop() {
if(status > 0) {
Serial.print("FIRE! ");
Serial.println(status);
status = 0;
}
}
// PIND & 0b00000100