I am having a weird issue.
I have one of the sparkfun lilypad development simple units. This is a snap apart lilypad with a pezio buzzer and 4 leds.
We are trying to program the Mr. Ed theme song to coincide with lights blinking on and off. The light turns on and the first note sounds and when the light turns off the next note sounds and so on.
When I simulate the following code on circuits.io, it plays and blinks correctly. When I load it up on the lilypad, when the light is set to low, it will not play the corresponding sound.
Here is the code... Anyone see anything it could be?
// This is a program that will play the Mr. Ed theme song and have the lights blink on and off in sequence
int buzzer = 9;
// Setting the speed of the notes
int eighth = 500; // This sets the tempo at eighth equals 120
int quarter = 2*eighth; // This sets the duration of the quarter note based on the length of the eighth
int dotquarter = eighth*3; // This sets the duration of the dotted quarter note .......
// Sets up the frequencies of the notes
int b3 = 247;
int c4 = 262;
int c4s = 277;
int d4 = 294;
int d4s = 311;
int e4 = 330;
int f4 = 349;
int g4 = 392;
int a4f = 415;
int a4 = 440;
int b4f = 494;
int b4 = 494;
int c5 = 523;
int d5 = 587;
void setup() {
// initialize pins as output.
pinMode(5, OUTPUT);//LED
pinMode(6, OUTPUT);//LED
pinMode(buzzer, OUTPUT);//buzzer
pinMode(10, OUTPUT);//LED
pinMode(11, OUTPUT);//LED
}
void loop() {
//the song with lights
digitalWrite(11, HIGH);
tone(buzzer, g4);
delay(eighth);
digitalWrite(11, LOW);
tone(buzzer, c5);
delay(eighth);
digitalWrite(10, HIGH);
tone(buzzer, b4);
delay(eighth);
digitalWrite(10, LOW);
tone(buzzer, a4);
delay(eighth);
digitalWrite(6, HIGH);
tone(buzzer, g4);
delay(quarter);
digitalWrite(6, LOW);
tone(buzzer, a4);
delay(eighth);
digitalWrite(5, HIGH);
tone(buzzer, e4);
delay(quarter);
digitalWrite(5, LOW);
tone(buzzer, g4);
delay(eighth);
}