Documente Academic
Documente Profesional
Documente Cultură
const int songLengthA = 38; //This are the notes, rythmes, total
length, and tempo for song A, B, and C
char notesA[] = "EbCDCbaaCEDCbCDECaa DFAGFECEDCbbCDECaa ";
int beatsA[] = {2,1,1,2,1,1,2,1,1,2,1,1,3,1,2,2,2,2,2,3,2,1,2,1,1,3,1,2,1,1,2,1,1,2,2,2,2,2};
int tempoA = 150;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(SongA, INPUT);
pinMode(SongB, INPUT);
pinMode(SongC, INPUT);
pinMode(RED_PIN, OUTPUT); //This section sets our pinmodes. Output pins
give power, whereas input pins recieve power.
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
digitalWrite(buzzerPin, LOW);
};
void loop() {
digitalWrite(buzzerPin, LOW);
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, LOW); //Sets all output pins to LOW, basically a reset.
digitalWrite(BLUE_PIN, LOW);
if ((digitalRead(SongA) == HIGH)) {
playSongA (); //Detects if Song A (Tetris)'s pin has power, if so, play said
song
digitalWrite(buzzerPin, LOW);
}
if ((digitalRead(SongB) == HIGH)) {
playSongB (); //Detects if Song B (Mario)'s pin has power, if so, play said
song
digitalWrite(buzzerPin, LOW);
};
if ((digitalRead(SongC) == HIGH)) {
red(); //
digitalWrite(buzzerPin, LOW); //Detects if Song C (Doom theme)'s pin has power, if
so, play said song
playSongC ();
digitalWrite(buzzerPin, LOW);
}
else (digitalWrite(buzzerPin, LOW));
}
}
int frequency(char note) //This function will set notes to their appropriate frequency
{
int i;
const int numNotes = 17; //The number of notes being stored
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'D', 'E', 'F', 'G', 'A', 's', 'l', 'w', 't'}; //Names of
notes being stored
int frequencies[] = {262, 294, 330, 349, 392, 440, 494, 523, 587, 660, 670, 784, 880, 466, 740,
622, 415}; //Frequencies of the notes being stored