#include <pitches.h>
const int pianoKeys[] = {8,7,6,5,4,3,2};
#define speaker 12
void setup() {
for(int i = 0; i < 9; i++) {
pinMode(pianoKeys[i],INPUT_PULLUP);
}
pinMode(speaker, OUTPUT);
}
void loop() {
int soundOutput = 0;
for(int i = 0; i < 9; i++) {
soundOutput = pianoKeys[i];
}
if(soundOutput){
tone(speaker, soundOutput);
}else{
noTone(speaker);
}
}