So how did you make the "pew" sound?
Hi @jim-p !
The answer is hidden in the youtube video in post 1.
It is based on the PCM library by David Mellis which you can find in the Arduino IDE Library Manager.
Or see here https://highlowtech.org/?p=1963
The project does not consider any protection of the controller involved.
![]()
I did something similar with an ESP32-C3, which has no I2S audio.
Converted my own audio clip to PCM with WAVToCode.
# WAVToCode
Leo..
I'm quite familiar with PCM audio but I' m still wondering how @asdf69 did it with that circuit
Sorry, I didn't want to question your knowledge...
If you follow the link in my post above you'll find a description how to create your own "pew" sound ... As it's also explained in the YouTube clip.
@asdf69
How did you make the "pew" sound with that circuit?
pam8403 is a 5V audio amplifier.
Give it external power. External to the Arduino, do not power it through the board just in case it wants around 200mA or more.
If you use 2 speakers, you can indeed feed the arduino output pin into L and R.
More sound is more current.
Those 2*3W amp boards can draw more than 1Amp.
You can't just feed a 5volt PWM signal into the inputs of that amp.
You must use an attenuating LC filter in between.
Leo..
Would that tend to change steps into waves?
Yes, depending on the filter parts and sound frequency.
so i figured out, there are 3 pins, L G R
G is ground, but it has no impact on anything, if its there ore not? probably internaly combined with the minus of the power (+ - )
the R is for the right speaker and the L is for the left speaker
No! G is the part that completes the circuit for both the L and the R pins.
How did you make the "pew" sound with that circuit?
problems
if i have only the pew sound and nothing else, like this, it works,
#include "pew.h"
#include "XT_DAC_Audio.h"
XT_Wav_Class Sound(pewData);
XT_DAC_Audio_Class DacAudio(25,0);
void setup() {DacAudio.Play(&Sound);}
void loop() {DacAudio.FillBuffer();}
but it makes an anoying sinus/tinitus sound when the pew is not activated( i have usb 5v with up to 3amp)
when i have it embeded into the code it gets even worse
instead of playing the pew sound once(it should last 0,6seconds), it is played three times and every time the sound level gets cut in third
it even gets worse when moveing the turret, the pew sound last 10 times and slowly gets silent
In post#1 I see a Nano.
The code in post#37 seems for an ESP32 with I2S sound (pin 25).
A Nano has no DAC or I2S.
Start with a middle-high note and slide it down at 1/time rate?
I'm thinking about how to make digital sound fade, there is no volume term in Arduino tone().
Middle C is 261.63 Hz (Google), the wavelength is 3822 micros so play a variable number of those out of every say 100 millis gives 26 steps of that note. If I play half as many then half as loud? I think it might sound weird.
In post #12 you said it worked, so what did you change?
