How to have arduino make sounds?

I just recently got an arduino, and I figured out how to make beeps with a piezo with it. However, I have not been able to find any tutorials on how to make other noises by using speakers and things. Any help is appreciated. :slight_smile:

There is a whole section on audio in playground:
http://www.arduino.cc/playground/Main/InterfacingWithHardware#Output

thanks, but I couldn't find a specific way to play songs or simply make a drum beat sound when you press a button how do you do that?

Sorry if I understand you wrong, but just go to the ArduinoIDE File>Examples>Digital>Melody

But make sure you understand the whole script, otherwise you won't learn anything from it :wink:

but I couldn't find a specific way to play songs or simply make a drum beat sound when you press a button how do you do that?

By itself, the Arduino doesn't have enough memory to play very large samples. For this, you'd need some form of external memory like an SD card and an audio shield , or a MIDI interface.

or:

http://www.ladyada.net/make/waveshield/

ALternatively you could connect it up to one of the many Sound Generator IC's on the market and get that to generate the sounds you want. This is a harder approach but would give you full control over the noises generated.

ALternatively you could connect it up to one of the many Sound Generator IC's on the market and get that to generate the sounds you want. This is a harder approach but would give you full control over the noises generated.

Or, take a look at this..... Google Code Archive - Long-term storage for Google Code Project Hosting.

An arduino should theoretically be able to produce more interesting waveforms than simple tones, given fairly simple external hardware (three resistors and an amp?) This is without going "all the way" to simply lpaying back pre-recorded sounds. There's a whole science (and art) to digital synthesis of music; and there were some impressive results back in the past (before simple sample and playback became possible.)

I've been a bit surprised not to have seen any more complex digital synthesizer hacks out of the arduino crowd; I thought there was a fair amount of overlap between experimentally minded music folk and the art/arduino community. Even some of the simpler "synthesizer toys" I've seen published seem to operate primarily in the digital realm (but not using a CPU. Hmmph.) But most of the hacks have involved just using Arduinos to provide input signals to more complicated commercial synthesizers...

We should get some like-minded folk together and do some experiments!

... or you could use our product, Rogue Robotics uMP3 Playback Module.

I'm whipping together a library now, so it should be as easy as:

ump3.play("/mysongs/song.mp3");

I'll update the playground once I get the library complete.

You can buy the module from RobotShop.us or from one of our other distributors.

b

I'm currently about to experiment with an SN76477 Sound Generator IC.

As an update, I've been experimenting with a hack of 3-bit DAC (1k, 560, 200 ohm resistors and a speaker),
and I've been able to get much more interesting sounds than the usual square-wave beep. For instance:

#define NOISEINT 30
void drumbeat(int len1, int len2)
{
  int i; 
  long t;
  for (i=0; i < len1; i++) {
    write_DA(random(8));  //attack
    delayMicroseconds(NOISEINT);
  }
  for (i=0; i < 30; i++) {
    write_DA(random(6));  //sustain
    delayMicroseconds(NOISEINT);
  }  
  for (i=0; i < 30; i++) {
    write_DA(random(4));  //sustain
    delayMicroseconds(NOISEINT);
  }  
  for (i=0; i < 30; i++) {
    write_DA(random(3));  //sustain
    delayMicroseconds(NOISEINT);
  }  
  for (i=0; i < 150; i++) {
    write_DA(random(2));  //decay
    delayMicroseconds(NOISEINT);
  }
  delay(len2 - 6);
  //  t = len2 - (20*len1) - (600+600+600+4000)
}

Any MP3's we can listen to?