14

I would like to play a wav file (spoken words) from my Arduino. I do not want to add a sound shield. Is there a way to play a sound through an output pin? The quality does not have to be great.

1
  • Does anyone know how to do it without an sd card? I really need to know for a school project that we have to finish in like 2 days. help? Mar 28, 2018 at 7:13

6 Answers 6

7

I helped someone with a similar question. The results are in my github repo at https://github.com/linhartr22/count. This example uses the PWM library and includes a reference to the article I used to learn how to convert audio files to MP3 with proper settings for the PWM libary. It plays audio through an 8 ohm speaker or a piezo buzzer connected directly to the Arduino.

4

The PCMAudio example shows how to play audio data via PWM. Note that you will need to access the MCU at a low level in order to do this; the Arduino libraries don't provide enough control over the hardware.

2

Yes, you can - see http://www.instructables.com/id/Simple-Wav-Player-Using-Arduino/

Space is quite limited, unless you use an SD card.

1

Yes, I did a project yesterday to play recorded voice. You don't need a speaker module.

Just connect the speaker via a resistor to one of Arduino PWM output. Then Connect a micro-sd card module. Format your micro-sd card with FAT32 Option.

Use Sample wave converter to convert your sound files and select the options as 16,000Hz Mono 8Bit. You are all done. Use tmrpcm library. It's all easy.

0

old post but still a good question...

Here is a tutorial for playing 8 bit 33khz audio using the Adafruit M0 Express. You can play ~60 seconds of audio from the 2MB onboard flash through the 10bit Analog out pin. https://github.com/hydronics2/SamdAudio

two other audio board solutions that offer near 16bit quality...

  • Adafruit's circuit python boards itsbyitsyM0, M4, feather M0. Same as above but using the circuit python interface instead of Arduino.

  • teensy3.2, teensy3.5, teensy3.6 (you can play out using the Analog pin without the audio shield but the audio shield has a nice 1/8" jack

Teensy Tutorial

Adafruit tutorial

3
  • 5
    Welcome to Arduino Stack Exchange! I am a bit puzzled by your answer because it is specifically about not using external hardware like a shield, but "to play a sound through an output pin". Thus your answer does not address the question at all.
    – Nick Gammon
    Mar 12, 2019 at 5:33
  • @NickGammon The boards suggested are not shields or add-on boards but instead alternative Arduino (like) hardware. I agree it is 100% to the question but it is still a worthy answer for those visiting this question.
    – sa_leinad
    Mar 13, 2019 at 3:40
  • @NickGammon hey Nick! I love your work.. I use your tutorials all the time. Yeah I guess I forgot to say that you can play 20-60 seconds of audio from onboard flash. The Adafruit M0 has 2MB of onboard external SPI flash.
    – hydronics
    Mar 20, 2019 at 14:45
0

@Hoytman i think this arduino library can help you a lot https://sensorium.github.io/Mozzi/

Not the answer you're looking for? Browse other questions tagged or ask your own question.