SciFi sounds for Piezo Buzzer

I've got the Melody function working with a piezo buzzer, but I'm actually trying to generate creepy sci-fi type sounds like a sonic screwdriver or a ray gun or that theremin sound from twilight zone and such. I don't want to use a speaker, just a buzzer. It shouldn't really be that difficult, I just have a terrible ear and couldn't deconstruct a sound if my life depended on it.

Here's what a sonic screwdriver sounds like, for reference: http://soundfxnow.com/sound-fx/doctor-who-sonic-screwdriver/

Here's the sorta-kinda-wibbly-wobbly code I've got running the buzzer right now.
It's close, but it's pretty irritating and I'd like to smooth it out and get it doing that nice oscillating thing. (I don't want to build an oscillator either. I'm mostly a software person, so I prefer to do it with code rather than more components)

Anyway, here it is. It probably just needs small adjustments from someone with a more trained ear:

tone(buzzerPin,2200); // then buzz by going high
    tone(buzzerPin,1000);
    tone(buzzerPin,500);
    tone(buzzerPin,200);
    tone(buzzerPin,500);
    delayMicroseconds(10000);    // waiting
    noTone(buzzerPin);  // going low
    delayMicroseconds(10000);    // and waiting more
    tone(buzzerPin,2200); 
    tone(buzzerPin,1000);
    delayMicroseconds(10000);    // waiting
    noTone(buzzerPin);  // going low
    delayMicroseconds(10000);    // and waiting more
    tone(buzzerPin,100); 
    delayMicroseconds(10000);    // waiting
    noTone(buzzerPin);  // going low
    delayMicroseconds(10000);    // and waiting more
    tone(buzzerPin,100); 
    delayMicroseconds(10000);    // waiting
    noTone(buzzerPin);  // going low
    delayMicroseconds(10000);    // and waiting more

Not sure if this helps, but here is a short clip or my Arduino playing the type of thing you may be looking for -

Its a very simple circuit, just five potentiometers, I guess you could figure out what settings produce the sounds you are looking for and go from there.

The Auduino source code is here - Google Code Archive - Long-term storage for Google Code Project Hosting.

You should consider a small speaker and amp, here is a short post with a simple amp, really easy to build and great sound -

Duane B

rcarduino.blogspot.com

Ahhhhhh! Why did my subscription to this thread not notify me that a cool person had replied to it!?!?!

That looks like a really fun music toy to play with, but I'm running a tiny piezo buzzer in a tiny space, and I just need to hit a switch and have it play a little sound effect. So no nifty pots in combination for me!

basically I just want to take some sci-fi sound effects and convert them to hertz so I can use them with; tone(frequency,duration).

I've downloaded a program that will convert any audio file to hertz values, but even with the shortest sound effects I always end up with a page or two full of numbers, which is too many. I want, max, like a series of 20 tones I can loop that make a nifty sci-fi sound. I made some good progress on the concept today, but everything sounded like 8bit video game music, which isn't really the effect I'm going for. I mean, if I wanted to play mary had a little lamb on my buzzer, I could just look up the hertz values for the notes (which are in the melody library already) and plug them in. But nobody write sheet music for sound effects, you know what I mean? If I could just get something like "oh yeah, the sonic screwdriver sound is BBBGAADEEFFGAGAGAAABBE" I would be golden.

Hi,

Its certainly possible to do what you want, but I doubt that you will find an off the shelf option.

I would build and Auduino as linked in on of my earlier responses - yes it does need five potentiometers, but if you use these to experiment and then note the values that sound closest to what you want you stand a really good chance of acheiving what your looking for.

You might also find something interesting here - most of it sounds like 8-bit video games but there are one or two that have an industrial or sci fi sound and as it takes about four minutes to build, whats to lose ?

The Auduino post can be found here,it also takes minutes to build and is probably closer to what your looking for, its the basic technique for complex sound generation -

I also have another project uses similar techniques to generate a more techno/industrial range of sounds, I will probably publish it later this week

Duane B

rcarduino.blogspot.com

DuaneB:
I would build and Auduino as linked in on of my earlier responses - yes it does need five potentiometers, but if you use these to experiment and then note the values that sound closest to what you want you stand a really good chance of acheiving what your looking for.

Also there is such a thing as a digital potentiometer. So it could be possible to replace the normal potentiometers and have a sketch with multiple or variable resistance values. Though the final signal might need additional amplification due to digipots only being able to handle relatively low currents.

Its much simpler than that, the pots are only there to provide analog inputs, lots of people use light sensors instead or as I was originally suggesting just use the pots to find the sounds you like, then hard code the values and remove the pots.

Duane B

greymaiden:
I've downloaded a program that will convert any audio file to hertz values, but even with the shortest sound effects I always end up with a page or two full of numbers, which is too many.

Do you have the name of the program you used?

Is there a library of arduino "tone" tunes anywhere?

Thanks.

greymaiden:
I've downloaded a program that will convert any audio file to hertz values,

Can you tell me what program you used for this please.

Hi everyone,
I see this is an old post. I was monkeying around today, and I got a reasonable sonic screwdriver sound out of a piezo, without sampling a .wav file or anything fancy. Try this code, future Dr. Who fans!

byte piezoPin = 4;                // pin for piezo. Long leg of piezo: pin 4, short leg: GND.
byte buttonPin = 10;              // pin for momentary switch (between Pin 10 and GND).

void setup()
{
 pinMode(piezoPin,OUTPUT);
 pinMode(buttonPin,INPUT_PULLUP); // set up buttonPin as input with internal pull-up resistor
}

void loop()
{
 if(digitalRead(buttonPin)==LOW){ // if button is pushed 
   //soundFX(3000.0,30+200*(1+sin(millis()/5000))); // wonky sonic screwdriver
   soundFX(3000.0,30); // sonic screwdriver
   //soundFX(100.0,30.0); // ray gun
   //soundFX(3.0,30.0); // star trek
   //soundFX(1.0,30.0); // star trek high
 }
}

void soundFX(float amplitude,float period){ 
 int uDelay=2+amplitude+amplitude*sin(millis()/period);
 for(int i=0;i<5;i++){
   digitalWrite(piezoPin,HIGH);
   delayMicroseconds(uDelay);
   digitalWrite(piezoPin,LOW);
   delayMicroseconds(uDelay);
 }
}

Hope this helps someone,
-Dave

1 Like