Go Down

Topic: Odd Lilypad issue with pezio and lights (Read 857 times) previous topic - next topic

istrait77

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?

Code: [Select]

//  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);
 
}




uxomm

Did you get any sound with your hardware jet?
Did you try the example sketch (from sparkfun wesite)?

istrait77

Yes.  With this program, the only time the notes would sound is when the lights were on.  For example...

//Note sounds here
  digitalWrite(11, HIGH);
  tone(buzzer, g4);
  delay(eighth);


//Note does not sound here....
  digitalWrite(11, LOW);
  tone(buzzer, c5);
  delay(eighth);

It is really odd...  I simulated it on Circuits.io and the program worked right the way it was supposed to, so this was definitely weird....

uxomm

Looks like you have a "hardware problem".
Maybe some pins shorted?
I do not have your hardware (I do have a Lilypad but not the special kit you mentioned), but both sketches you posted work pretty well with my setup: Lilypad, buzzer, some LEDs with resistors...

istrait77

That must be it....  I am glad someone else tested it and found no issues...

Thanks...

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy