Library to control Electret Microphone Amplifier - MAX9814 from adafruit. Allows: To sample analogue voltage to transform into rough sound level. Transfer sound level to visual indicator, volume bar such as 4 LEDs on LPC11U24.

Dependents:   MAX9814_LED_Sound_Indicator

Revision:
1:cf181e6a2ead
Parent:
0:49d2ee7cb020
--- a/MAX9814.cpp	Sun Nov 02 17:32:03 2014 +0000
+++ b/MAX9814.cpp	Sun Nov 02 18:42:52 2014 +0000
@@ -1,3 +1,8 @@
+/*
+    MAX9814.cpp - MAX9814 sensor library
+    Developed by Andrea Corrado   
+*/
+
 #include "mbed.h"
 #include "MAX9814.h"
 
@@ -6,40 +11,6 @@
 }
 
 
-void MAX9814::led_array(float x ) {
-
-    if (_value<x+0.05) {
-            _led1=0;
-            _led2=0;
-            _led3=0;
-            _led4=0;
-    }
-    if (_value>x+0.05&&_value<0.5+x) {
-            _led1=1;
-            _led2=0;
-            _led3=0;
-            _led4=0;
-    }
-    if (_value>0.5+x&&_value<1+x) {
-            _led1=1;
-            _led2=1;
-            _led3=0;
-            _led4=0;
-    }
-    if (_value>1+x&&_value<1.2+x) {
-            _led1=1;
-            _led2=1;
-            _led3=1;
-            _led4=0;
-    }
-    if (_value>1.2+x&&_value<2.8+x) {
-            _led1=1;
-            _led2=1;
-            _led3=1;
-            _led4=1;
-    }
-}
-
 float MAX9814::calibration() {
     
     _t.start();
@@ -97,6 +68,39 @@
     return _value;
 }
 
+void MAX9814::led_array(float x ) {
+
+    if (_value<x+0.05) {
+            _led1=0;
+            _led2=0;
+            _led3=0;
+            _led4=0;
+    }
+    if (_value>x+0.05&&_value<0.5+x) {
+            _led1=1;
+            _led2=0;
+            _led3=0;
+            _led4=0;
+    }
+    if (_value>0.5+x&&_value<1+x) {
+            _led1=1;
+            _led2=1;
+            _led3=0;
+            _led4=0;
+    }
+    if (_value>1+x&&_value<1.2+x) {
+            _led1=1;
+            _led2=1;
+            _led3=1;
+            _led4=0;
+    }
+    if (_value>1.2+x&&_value<2.8+x) {
+            _led1=1;
+            _led2=1;
+            _led3=1;
+            _led4=1;
+    }
+}
 
 void MAX9814::volume_indicator() {
         led_array(_average);