Read amplitude from piezo buzzer

Hi,

Can I read amplitude from a piezo buzzer? How? or at least my code can define loudness of a sound.

For example:
Loud == 01
Quiet == 10
.etc

If you are not using a pot, there's not much point in "reading" the level since your software should already know.

A 50% [u]duty cycle[/u] will give you the loudest sound (with a fixed 5V square/rectangular wave). A duty cycle of zero or near 100% will be silent.

This will also change the harmonic content, so it will change the "character" of the sound (without changing fundamental or perceived the pitch). You might not notice the change of character with high-frequencies & piezo, but you'd notice it with lower frequencies and a speaker.

Hi, thanks for the reply

I know that potentiometer can read analog value 0-1023. Can I use that same approach for piezo bouzer? at what value loud and silent sound can define?

Reading from a POT is A-to-D. (analogRead)
Outputting a voltage to drive a piezo with varying intensity is D-to-A. (analogWrite)
Please try to clarify what it is you are trying to do with the Piezo.