This is my full code if it helps. I know it's ugly. I have read and fully understand the blink tutorial and don't see how it is relevant.
int ledPins[] = {3,4,5,6,7,8,9,10}; /*this array holds the
pins the LEDs are connected
to (LED #0 = pin 3 etc.) */
int speakerPin = 11; //sets piezo pin to PWM pin 11
int length = 30; // the number of notes: 31
char notes[] = "rfgarfgabtsrbtsrCgabCgabaCEGEG";
int beats[] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 4, 2, 6};
int tempo = 200;
void playTone(int tone, int duration)
{
for(long i = 0; i < duration * 1000L; i += tone * 2)
{
digitalWrite (speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite (speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration)
{
char names[] = {'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'r', 's', 't', 'E', 'G'};
int tones[] = {1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 1073, 1205, 1355, 758, 638 };
//play the tone corresponding to the note name
for (int i = 0; i < 14; i++)
{
if(names[i] == note)
{
playTone(tones[i], duration);
}
}
}
void musicPlaying(){
for(int i = 0; i < length; i++)
{
if(notes[i] == ' ')
{
delay(beats[i] * tempo); //rest
}
else
{
playNote(notes[i], beats[i] * tempo);
}
//pause between notes
delay(tempo/2);
}}
void oneOnAtATime1()
{
int delayTime = 500; //time to pause (ms) between LEDs)
for(int j = 0; j <=7; j++)
{
int offLED = j - 1; //this calculates the previously on LED
if(j == 0)
{
offLED = 7;
}
digitalWrite(ledPins[j], HIGH); //turn on LED i
digitalWrite(ledPins[offLED], LOW);
delay(delayTime);
}
}
void oneOnAtATime2()
{
int delayTime = 400; //time to pause (ms) between LEDs)
for(int j = 0; j <=7; j++) //i is increased by 1 until it is <= 7
{
int offLED = j - 1; //this calculates the previously on LED
if(j == 0)
{
offLED = 7;
}
digitalWrite(ledPins[j], HIGH); //turn on LED i
digitalWrite(ledPins[offLED], LOW);
delay(delayTime);
}
}
void oneOnAtATime3()
{
int delayTime = 300; //time to pause (ms) between LEDs)
for(int j = 0; j <=7; j++) //i is increased by 1 until it is <= 7
{
int offLED = j - 1; //this calculates the previously on LED
if(j == 0)
{
offLED = 7;
}
digitalWrite(ledPins[j], HIGH); //turn on LED i
digitalWrite(ledPins[offLED], LOW);
delay(delayTime);
}
}
void allFlash()
{
for(int loopLimit = 0; loopLimit < 5; loopLimit++)
{
delay(500);
digitalWrite(ledPins[0], HIGH);
digitalWrite(ledPins[1], HIGH);
digitalWrite(ledPins[2], HIGH);
digitalWrite(ledPins[3], HIGH);
digitalWrite(ledPins[4], HIGH);
digitalWrite(ledPins[5], HIGH);
digitalWrite(ledPins[6], HIGH);
digitalWrite(ledPins[7], HIGH);
delay(500);
digitalWrite(ledPins[0], LOW);
digitalWrite(ledPins[1], LOW);
digitalWrite(ledPins[2], LOW);
digitalWrite(ledPins[3], LOW);
digitalWrite(ledPins[4], LOW);
digitalWrite(ledPins[5], LOW);
digitalWrite(ledPins[6], LOW);
digitalWrite(ledPins[7], LOW);
}
}
void setup()
{
pinMode(speakerPin, OUTPUT);
for(int i = 0; i < 8; i ++)
{
pinMode(ledPins[i], OUTPUT); /*this is a shortcut to make all
LEDs "output"*/
}
}
void loop()
{
musicPlaying();
oneOnAtATime1();
oneOnAtATime2();
oneOnAtATime3();
allFlash();
}