CodeShare
Dependencies: mbed
Fork of SPW2430_Microphone_Hello_World by
Revision 0:1a0cc42c459d, committed 2015-11-28
- Comitter:
- 4180_1
- Date:
- Sat Nov 28 01:48:05 2015 +0000
- Commit message:
- ver 1.0
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 1a0cc42c459d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 28 01:48:05 2015 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +//Adafruit MEMs SPW2430 microphone demo - LEDs display audio level +BusOut myleds(LED1,LED2,LED3,LED4); + +class microphone +{ +public : + microphone(PinName pin); + float read(); + operator float (); +private : + AnalogIn _pin; +}; +microphone::microphone (PinName pin): + _pin(pin) +{ +} +float microphone::read() +{ + return _pin.read(); +} +inline microphone::operator float () +{ + return _pin.read(); +} + +microphone mymicrophone(p16); + +int main() +{ + while(1) { +//read in, subtract 0.67 DC bias, take absolute value, and scale up .1Vpp to 15 for builtin LED display + myleds = int(abs((mymicrophone - (0.67/3.3)))*500.0); +//Use an 8kHz audio sample rate (phone quality audio); + wait(1.0/8000.0); + } +}
diff -r 000000000000 -r 1a0cc42c459d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 28 01:48:05 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file