// Entête déclatative.
#include "Pitche.h"
const int btnPins[8] = {12, 11, 10, 9, 8, 7, 6, 5};
const int buzzer = 13;
const int btnNotes[8] = {
NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4,
NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5
};
void setup() {
pinMode(buzzer, OUTPUT);
for (int i = 0; i < 8; i++) {
pinMode(btnPins[i], INPUT_PULLUP);
}
}
void loop() {
int pitch = 0;
for (int i = 0; i < 8; i++) {
if (digitalRead(btnPins[i]) == LOW) {
pitch = btnNotes[i];
}
}
if (pitch) {
tone(buzzer, pitch);
} else {
noTone(buzzer);
}
}