From a13a9ec1a71dac685fe831bd87d259b59997d441 Mon Sep 17 00:00:00 2001 From: Omar Ali Hassan <36759605+OmarAli3@users.noreply.github.com> Date: Wed, 18 Mar 2020 00:29:36 +0200 Subject: [PATCH] Changing amplitude example to output values in dB --- examples/AmplitudeSerialPlotter/AmplitudeSerialPlotter.ino | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/AmplitudeSerialPlotter/AmplitudeSerialPlotter.ino b/examples/AmplitudeSerialPlotter/AmplitudeSerialPlotter.ino index 3d768a3..394c9e2 100644 --- a/examples/AmplitudeSerialPlotter/AmplitudeSerialPlotter.ino +++ b/examples/AmplitudeSerialPlotter/AmplitudeSerialPlotter.ino @@ -49,8 +49,9 @@ void loop() { if (amplitudeAnalyzer.available()) { // read the new amplitude int amplitude = amplitudeAnalyzer.read(); - - // print out the amplititude to the serial monitor - Serial.println(amplitude); + //dB relative to full scale + int dpFS = 20 * log10(abs(amplitude)); + // print out the decibel to the serial monitor + Serial.println(dpFS); } }