#include "pitches.h"
#define SPEAKER_PIN 8
const uint8_t buttonPins[] = { 12, 11, 10, 9, 7, 6, 5, 4 };
const int buttonTones[] = {
NOTE_C4, NOTE_D4, NOTE_E4, NOTE_F4,
NOTE_G4, NOTE_A4, NOTE_B4, NOTE_C5, NOTE_GS3
};
const int song[] = {
4, 4, 5, 6, 6, 5, 4, 3, 2, 2, 3, 4, 4, 3, 3,
4, 4, 5, 6, 6, 5, 4, 3, 2, 2, 3, 4, 3, 2, 2,
3, 3, 4, 2, 3, 4, 5, 4, 2, 3, 4, 5, 4, 3, 2, 3, 9, 4,
4, 5, 6, 6, 5, 4, 5, 3, 2, 2, 3, 4, 3, 2, 2
};
const int songt[] = {
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 4,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 1, 4,
2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 4,
2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 3, 1, 4
};
const int numTones = sizeof(buttonPins) / sizeof(buttonPins[0]);
int a = 250;
void setup() {
for (uint8_t i = 0; i < numTones; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
int pitch = 0;
for (uint8_t i = 0; i < 63; i++){
tone(SPEAKER_PIN, buttonTones[song[i]]);
delay(a*songt[i]);
noTone(SPEAKER_PIN);
delay(80);}
}