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.
Dependencies: 4DGL-uLCD-SE SDFileSystem
Revision 4:f5bc5d9a790b, committed 2016-09-23
- Comitter:
- fkhan39
- Date:
- Fri Sep 23 19:45:44 2016 +0000
- Parent:
- 3:99acbebbed6c
- Child:
- 5:151b0fa1fb44
- Commit message:
- added mems microphone test;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Sep 23 19:34:38 2016 +0000
+++ b/main.cpp Fri Sep 23 19:45:44 2016 +0000
@@ -1,5 +1,42 @@
#include "mbed.h"
+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);
+ }
+}
+/*
+
AnalogOut aout(p18);
AnalogIn ain(p15);
DigitalOut led1(LED1);
@@ -9,6 +46,9 @@
int main()
{
+
+
+ /*
// part 1
const double pi = 3.141592653589793238462;
const double amplitude = 1.0f;
@@ -66,4 +106,3 @@
printf("Done\n");
*/
-}
\ No newline at end of file
