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: mbed
main.cpp
00001 #include "stdio.h" 00002 #include "mbed.h" 00003 #include "stdlib.h" 00004 00005 //DigitalOut myLED(LED2); 00006 AnalogIn mic(A6); 00007 00008 int main(void) 00009 { 00010 float values[1000]; 00011 float maxvals[1000]; 00012 //float absmaxval[1000]; 00013 //int length1; 00014 //char crudePeakValues[500]; 00015 //int peakValues[500]; 00016 //int indexDifference[500]; 00017 00018 printf("hello read me\n"); 00019 00020 for (int i = 0; i < 1000; i++) { 00021 values[i] = mic.read(); 00022 printf("%f \n",values[i]); 00023 } 00024 for (int i = 0; i < 1000; i++) { 00025 printf("%f \n",values[i]); 00026 // wait_ms(200); 00027 } 00028 // printf("Hello, out of first for loop \n"); 00029 // wait(5); 00030 00031 int j = 0; 00032 for (int i = 1; i < 999; i++){ 00033 printf("Hello reached second for loop \n"); 00034 if (values[i] > values[i-1] && values[i] > values[i+1]){ 00035 maxvals[j] = values[i]; 00036 j++; 00037 printf("I LOVE CAPSTONE"); 00038 } 00039 else { 00040 printf("HELLO"); 00041 } 00042 } 00043 00044 //length1 = sizeof(maxvals) / sizeof (float); 00045 //printf("%i \n", length1); 00046 00047 /* for (int i = 1; i < 999; i++){ 00048 if (maxvals[i] > maxvals[i-1] && maxvals[i] > maxvals[i+1]{ 00049 absmaxvals[i] = maxvals[i]; 00050 } 00051 } 00052 00053 */ 00054 00055 } 00056 00057 00058 //for (int i = 0; i < 1000; i++) { 00059 // printf("%f \n", values[i]); 00060 // } 00061 00062 00063 00064 //nested for loop 00065 //will find where in the first 1000 digitzed values there is a digitized value above the selected threshold 00066 //will then store the indice for that value in a new array called peakvalues 00067 /* for (int i = 0; i < 1000; i++) { 00068 for (int t = 0; t < 500; t++) { 00069 if (values[i] > "threshold") { //amplitude for 2.9 kHz sound changes as the distance from the microphone changes 00070 if (values[i] > values[i - 1] && values[i] > values[i + 1]) 00071 crudePeakValues[t] = values[i]; 00072 } 00073 for (int y = 0; y < 500; y++) 00074 if (crudePeakValues[t] > crudePeakValues[t-1] && crudePeakValues[t] > crudePeakValues[t + 1]) 00075 peakValues[y] = t; 00076 } 00077 } 00078 00079 */
Generated on Sun Aug 21 2022 12:07:51 by
1.7.2