Weather control switch for connected day. NXP LPC 1768 module. Ethernet connectivity.
Dependencies: EthernetInterface mbed-rtos mbed nanoservice_client_1_12
Fork of Trenton_Switch_LPC1768_WIFLY by
Diff: MAX9814/MAX9814.cpp
- Revision:
- 26:3467812d5832
- Parent:
- 25:cb16c5248769
--- a/MAX9814/MAX9814.cpp Wed Dec 03 09:03:29 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - MAX9814.cpp - MAX9814 sensor library - Developed by Andrea Corrado -*/ - -#include "mbed.h" -#include "MAX9814.h" - -MAX9814::MAX9814(PinName pin): _pin(pin) { //, _led1(LED1), _led2(LED2), _led3(LED3) { - -} - - - -float MAX9814::sound_level() { - - _t.start(); - float peakToPeak=0, signalMax=0, signalMin=1024; - - while (_t.read_ms()<50) { - _sample=_pin.read(); - - if (_sample<1024) { - if (_sample>signalMax) - signalMax=_sample; - - else if (_sample<signalMin) - signalMin=_sample; - } - } - _t.stop(); - _t.reset(); - peakToPeak=signalMax-signalMin; - _value= (peakToPeak*3.3); - _value = floor(_value * 100) / 100; - - return _value; -}