//void setup()
//{
//digitalWrite (BLUE_LED, HIGH);
//digitalWrite (GREEN_LED, HIGH);
//digitalWrite (RED_LED, HIGH);
//delay (3000);
//}
//void loop()
//{
//}
// Pitches Explorations
int buzzer = 8; // represents which slot on the device that the music is connected to
int duration[] = {500, 500,500,500,500,500,1000,500,500,500,500,500,500,1000,500, 500,500,500,500,500,1000,500,500,500,500,500,500,1000,500, 500,500,500,500,500,1000,500,500,500,500,500,500,1000} ; // introducing the integer called duration of each note representing quarter and half notes
int pitch[] = {130.81, 130.81, 196, 196, 220, 220, 196, 174.61,174.61,164.81,164.81,146.83,146.83,130.81,196,196,174.61,174.61,164.81,164.81,146.83,196,196,174.6,174.6,164.81,164.81,146.83,130.81, 130.81, 196, 196, 220, 220, 196, 174.61,174.61,164.81,164.81,146.83,146.83,130.81}; // represents the note represented and number values allowing the device to understand
int BLUE_LED = 10;
int GREEN_LED = 11;
int RED_LED = 9;
int blue[] = {255,0,12,55,77,33,99,44,189,75,155,87,125,199,44,233,0,255,0,234,67,34,99,137,76,96,234,77,126,99,33,22,76,196,234,77,126,99,33,22,0,0};
int green[] = {0,255,0,234,67,34,99,17,76,96,234,77,16,99,33,22,0,0,25,12,33,44,66,88,99,13,22,65,127,85,25,62,255,0,12,55,77,33,99,44,189,75};
int red[] = {0,0,255,12,33,44,66,88,99,123,212,65,127,85,255,162,255,0,12,55,77,33,99,44,189,75,155,187,125,199,44,23,199,137,76,96,234,177,126,99,33,2};
void setup() // The code placed within the curly brackets of setup will run once.
{
pinMode(buzzer, OUTPUT); // declares that the buzzer will have an output of music through the buzzer
pinMode (BLUE_LED, OUTPUT);
pinMode (GREEN_LED, OUTPUT);
pinMode (RED_LED, OUTPUT);
}
void loop() // The code placed within the curly brackets of loop will run infinitely many times.
{
for (int i = 0; i < 42; i++) // The code placed within the curly brackets of the for cycle will repeat for every value of the integer i, ranging from 0 to 42, increasing by 1 for each repetition. there are 42 different notes
{
analogWrite (BLUE_LED, blue[i]);
//delay(duration[i]);
analogWrite (GREEN_LED,green[i] );
//delay(duration[i]);
analogWrite (RED_LED, red[i]);
tone(buzzer, pitch[i]); // The buzzer plays the frequency specified by the [i]th item in the pitch array.
//delay(duration[i]);
delay(duration[i]); //[] = {130.81, 130.81, 196, 196, 220, 220, 196, 174.61,174.61,164.81,164.81,146.83,146.83,130.81}; // note beat ex: quarter note
noTone(buzzer); // Turn off the buzzer.
delay(100); // Wait for the amount of time before next note 100 miliseconds.
}
delay(2000); // Wait for 2 seconds before playing song again
}