producing sound using STM32

Thread Starter

pistons4550

Joined Jul 8, 2013
6
Hello,

Im in the middle of a project, building RC cars that fight each other. The cars try to target switches on the other cars to lower their health status. Ive already got some LEDs to indicate a hit and now Id like to add some noise. Im wondering how I can create a sound after a hit using a small speaker. I know that the speakers on my stereo have two different wires to complete a circuit. Im wondering if hooking up a small speaker to my stm32F407VG board would be as simple as hooking up an LED, one leg to an output pin and another to ground. Any ideas on speakers, programming sound, or comments in general?
 

MrChips

Joined Oct 2, 2009
35,130
STM32F407 has DAC outputs and loads of memory.
It depends on the duration of the sound and quality.
You can get fairly decent quality with just 8-bit data and low data rates such as 10ksps.

How long a sound bite do you want to create?
 

MrChips

Joined Oct 2, 2009
35,130
STM32F407VG has 1MB flash and 192KB SRAM.

4 seconds at 10Ksps requires 40KB which is easily accommodated.

Now what you need to do is create the sound bite on a PC and then burn this into the STM FLASH memory.

I can show you how to set up the DMA to output the sound wave to a DAC.

What IDE platform are you running?
 

Thread Starter

pistons4550

Joined Jul 8, 2013
6
this is my first time messing with this board, other than the LED network and some external switches, I haven't done much else with it
 

bloguetronica

Joined Apr 27, 2007
1,544
By the way. If you want to attach a speaker directly to a DAC output, you should consider using a electrolytic capacitor for DC decoupling, in series with the speaker.
 
Top