#include "pitches.h"
volatile bool enableNoteA3 = false;
volatile bool enableNoteG3 = false;
void setup() {
pinMode(18 ,INPUT);
pinMode(21 ,INPUT);
attachInterrupt(digitalPinToInterrupt(18), toggleA3, RISING);
attachInterrupt(digitalPinToInterrupt(21), toggleG3, RISING);
}
void loop() {
if (enableNoteA3) {
tone(8, NOTE_A3, 1000);
}
if (enableNoteG3) {
tone(8, NOTE_G3, 1000);
}
if (!(enableNoteA3 || enableNoteG3)) {
noTone(8);
}
}
void toggleA3() {
enableNoteA3 = !enableNoteA3;
}
void toggleG3() {
enableNoteG3 = !enableNoteG3;
}