Making a piezo hiss

Is there any particular frequency (or control technique?) you can use to make a piezo (or other speaker) hiss loudly? Imagine a sound like a cat hissing, or a compressed air duster.

A hiss is the result of what is known as white noise. You can approximate it by passing random numbers to the D/A.

Sorry, this is my first project. What's the D/A?

It is a Digital to Analogue converter.

What Arduino are you using and what are you doing to output the sound?

The way you asked the question sounded like you knew about sound output but wanted to know about this. It sounds now like you know nothing about sound. A lot depends on what you have and what you want to do.

NOTE - I have NOT tried this code! If it doesn't work, you'll have to debug it yourself. ;)

I modified the Blink LED example for random pulses (constrained to the higher-end of the audio spectrum for a piezo speaker).

Connect your piezo to pin 13, or change to code to address whatever pin you are using.

That should give you a hiss-like noise.

If you use a regular speaker (with an amplifier, of course), you can increase 500uS limit to include lower frequencies (longer period). You might want to try that even with a piezo, since lower-frequency pulses will contain high-frequency harmonics that the piezo can product.

Modified for random noise.

   Most Arduinos have an on-board LED you can control. On the Uno and
   Leonardo, it is attached to digital pin 13. If you're unsure what
   pin the on-board LED is connected to on your Arduino model, check
   the documentation at

   This example code is in the public domain.


// the setup function runs once when you press reset or power the board
void setup() {
   // initialize digital pin 13 as an output.
   pinMode(13, OUTPUT);

// the loop function runs over and over again forever
void loop() {
   digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
   delayMicroseconds( (random(50, 500) );              // wait for random time
 digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delayMicroseconds( (random(50, 500) );               // wait for random time

hiss loudly?

You can't control the loudness without a DAC, and you might need an amplifier with a volume control. You'd probably need an amplifier with at least a few watts of power and a good-sized speaker to the same loudness as a compressed-air nozzle.


Take a look at [url=[/url]**[u]this post[/u]**[/url]. The code was accidently producing noise...