HOW PWM PINS CREATE SOUND WHEN CONNECTED TO SPEAKERS

Greetings all
I want to know that how PCM library by converting audio to some numbers using PWM pins of arduino creates different sound.
I searched a lot but couldn't find any thing on the web.
Thanks in advance

mr7919:
I searched a lot but couldn't find any thing on the web.

This link is good: http://lmgtfy.com/?q=pwm&l=1

I want to ask that how the tmrpcm library uses the timers to produce different sounds and the link you provided was the 1st which i had read

mr7919:
I want to ask that how the tmrpcm library uses the timers to produce different sounds and the link you provided was the 1st which i had read

First the PWM frequency is raised to something above the maximum audio frequency.
Then the sound samples are written to change the PWM duty cycle as then the PWM is then acts like an D/A converter. These samples can come from either a file or the result of some algorithm.

in the pcm library there is a large code corresponding to the audio files.What is that thing

@mr7919 : Please feel free to share any code or links you may feel relevant.

mr7919:
in the pcm library there is a large code corresponding to the audio files.What is that thing

It is the waveform samples.
Is this homework?

these are waveform samples but how does they help to produce different sound.Sorry I am stupid :zipper_mouth_face:

mr7919:
I want to ask that how the tmrpcm library uses the timers to produce different sounds and the link you provided was the 1st which i had read

The tmrpcm library uses exactly the techniques on that page.

mr7919:
these are waveform samples but how does they help to produce different sound.Sorry I am stupid :zipper_mouth_face:

The data is a list of the width of the pulses.

ok thanks but say the code is 128,100,45,30 the width is in what units

mr7919:
ok thanks but say the code is 128,100,45,30 the width is in what units

"Duty cycle" of the pulse. 0=narrowest, 255=widest

mr7919:
these are waveform samples but how does they help to produce different sound.

Read this:-

thank you all for your responses. :slight_smile: