Generating sounds

sbscott

Senior Member
Working on a robot (car) for my granddaughter and want to generate some clever sounds (using the Sound command) when it detects objects or drop off etc. Has anyone worked up a list of interesting sounds that I could grab? Like 'shrieks' or 'clap' or 'kaboom' etc? I have done a few searches but nothing pops out that would work.

Thanks
 

westaust55

Moderator
The PICAXE parts have three commands for audible output.

SOUND - intended to beeps (when say wanting feedback using a keypad) or simple noises

PLAY and TUNE - intended more for musical tunes using standard musical notes.

I am not aware of any past posts on the PICAXE forum trying to use the inbuilt commands for the type of sounds you seek. You may be on your own there unless someone comes forward with some examples of what they have done.

Some folks have used 3rd party audio modules which play MP3 or other sound files and connect via SPI or i2c comms
 

The bear

Senior Member
@sbscott,
Search; engine noise, by, "the old fart" dated 05.09.15 (I haven't mastered forum links yet).

Help required, simulate variable diesel engine noise.

Regards, Bear..
 

AllyCat

Senior Member
Hi,

The finished project is here but I believe TOF moved on to using a WAV file player for better results.

Certainly IMHO, using PWM is the way to go: It can operate in the "background" (whilst the program is doing something else) with potentially up to 4 channels ("tones") available at the same time. It may not even be necessary to use busby's trick (which potentially "wastes" two pins), because a PWMOUT pin,256,512 can sound much louder than (say) a PWMOUT pin,256,1 even though the fundamental frequency should be the same.

However, note that "square wave" sounds (as from a pWM output) can seem very "harsh", so a low pass filter may be beneficial. Personally, I would try a set different resistor values (perhaps in a ratio 1:2:4:8 or even greater) from different PWM output pins, "mixing" onto a single filter capacitor (and amplifier and/or sounder). That gives the potential for selecting different "cutoff" frequencies and/or multiple tones, etc.. But you may need a good "ear" and some persistence for successful results.

Cheers, Alan.
 
Top