Author Topic: Programming simple music tones with a piezospeaker?  (Read 2915 times)

0 Members and 1 Guest are viewing this topic.

Offline jbeanTopic starter

  • Jr. Member
  • **
  • Posts: 7
  • Helpful? 0
Programming simple music tones with a piezospeaker?
« on: February 08, 2008, 03:51:30 PM »
I am building my first robot using the BOE-BOT from parallax and i just got to the part with the piezospeaker.  I was thinking that if you had a certain code that changed the frequency of the speaker in a specific order you may be able to make a cool little music tune or sound.  Just wondering if anyone has any experience with this.

Also,  I am looking for a good site that has example programs to run on the basic stamp II.

Thanks!

Offline gamefreak

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: Programming simple music tones with a piezospeaker?
« Reply #1 on: February 08, 2008, 05:00:45 PM »
woot the BOE-BOT!

Yea you could, right now with the 50$ robot im adding a peziospeaker for startup tunes and various warning sounds. I do not think that a peziospeaker has a very wide frequency range, but I could be wrong...
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline bietz

  • Full Member
  • ***
  • Posts: 48
  • Helpful? 0
Re: Programming simple music tones with a piezospeaker?
« Reply #2 on: February 09, 2008, 04:53:11 AM »
Quote
Also,  I am looking for a good site that has example programs to run on the basic stamp II.


First of all, read the book because it's got lots of cool stuff in it and it is written very well. Then Parallax.com ! They've got tons of downloadable pdfs of all their stamps in class educational books. Here are all the Stamps in Class books, freely downloadable. And you can also download pdfs of all the articles about basic stamps on nuts and volts magazine, at the archive here.

Anyways, to make tones with the piezospeaker, all you have to do is use simple FREQOUTs with the appropriate frequencies.
You could declare some constants first, for the frequencies of the notes you use (you can find note frequencies tables easily on the web), like:
Code: [Select]
A CON 880
B CON 988
C CON 1047
etc.

then you could either just write your FREQOUT statements one after the other, or you could store a sequence of notes in EEPROM with the DATA command (more on that is in the BOE bot book), then play the sequence with a FOR loop with a single FREQOUT command inside the loop.

But I'm sure there are some articles about this on the internet. Try to search it on the parallax forums too.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: Programming simple music tones with a piezospeaker?
« Reply #3 on: February 17, 2008, 09:40:01 AM »
controlling a peizo is exactly the same as controlling a servo (code wise), you just need to change the frequency

 


Get Your Ad Here