From 6e8b0dd038f2c552979c323ae801de75bd22182c Mon Sep 17 00:00:00 2001 From: Sarah Knepper Date: Wed, 14 Jan 2015 16:46:37 -0800 Subject: [PATCH] mic: Add comments to C++ example for Grove microphone/sound sensor Signed-off-by: Sarah Knepper --- examples/mic.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/mic.cxx b/examples/mic.cxx index 2c9ac460..8773d716 100644 --- a/examples/mic.cxx +++ b/examples/mic.cxx @@ -46,6 +46,7 @@ sig_handler(int signo) int main(int argc, char **argv) { + // Attach microphone to analog port A0 sensor = new upm::Microphone(0); signal(SIGINT, sig_handler); @@ -54,6 +55,10 @@ main(int argc, char **argv) ctx.runningAverage = 0; ctx.averagedOver = 2; + // Infinite loop, ends when script is cancelled + // Repeatedly, take a sample every 2 microseconds; + // find the average of 128 samples; and + // print a running graph of the averages while (!is_running) { int len = sensor->getSampledWindow (2, 128, buffer); if (len) {