// Déclaration des constantes et variables

const int PinTone = 3;
const int PinButton[] = {12,11,10,9,8};
const int Notes[] = {262,294,330,349,392};
const int NoteDurations[] = {4,4,4,4,8};

int PlayNote = 0;
int Note = 0;
int NoteDuration = 0;


// Initialisation des entrées et sorties

void setup() {  
for(int i = 0 ; i < 5 ; i++)
{
  pinMode (PinButton[i], INPUT);
} 
}


// Fonction principale en boucle

void loop() {
  
  if (digitalRead(PinButton[0]) == HIGH) {
    PlayNote = 1;
    Note = 0;
  }
  if (digitalRead(PinButton[1]) == HIGH) {
    PlayNote = 1;
    Note = 1;
  }
  if (digitalRead(PinButton[2]) == HIGH) {
    PlayNote = 1;
     Note = 2;
  }
  if (digitalRead(PinButton[3]) == HIGH) {
    PlayNote = 1;
    Note = 3;
  }
  if (digitalRead(PinButton[4]) == HIGH) {
    PlayNote = 1;
    Note = 4;
  }
  if (PlayNote == 1) {
    NoteDuration = int(1000/NoteDurations[Note]);
    tone(PinTone, Notes[Note], NoteDuration);
    delay(1.3*NoteDuration);  
    PlayNote = 0;
  }
}
