Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 //Adafruit MEMs SPW2430 microphone demo - LEDs display audio level 00003 BusOut myleds(LED1,LED2,LED3,LED4); 00004 00005 class microphone 00006 { 00007 public : 00008 microphone(PinName pin); 00009 float read(); 00010 operator float (); 00011 private : 00012 AnalogIn _pin; 00013 }; 00014 microphone::microphone (PinName pin): 00015 _pin(pin) 00016 { 00017 } 00018 float microphone::read() 00019 { 00020 return _pin.read(); 00021 } 00022 inline microphone::operator float () 00023 { 00024 return _pin.read(); 00025 } 00026 00027 microphone mymicrophone(p16); 00028 00029 int main() 00030 { 00031 while(1) { 00032 //read in, subtract 0.67 DC bias, take absolute value, and scale up .1Vpp to 15 for builtin LED display 00033 myleds = int(abs((mymicrophone - (0.67/3.3)))*500.0); 00034 //Use an 8kHz audio sample rate (phone quality audio); 00035 wait(1.0/8000.0); 00036 } 00037 }
Generated on Fri Jul 15 2022 03:58:37 by
1.7.2
Adafruit MEMS Microphone Breakout - SPW2430