Afinador Guitarra Incompleto
Dependencies: NVIC_set_all_priorities FastAnalogIn TextLCD mbed-dsp mbed
Revision 0:2b9337ff25fe, committed 2015-11-21
- Comitter:
- ratak477
- Date:
- Sat Nov 21 00:12:06 2015 +0000
- Child:
- 1:b5bd45c95e36
- Commit message:
- Afinador_Guitarra_Inc
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMSIS_DSP_401.lib Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emh203/code/CMSIS_DSP_401/#3d9c67d97d6f
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FastAnalogIn.lib Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/FastAnalogIn/#afc3b84dbbd6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,118 @@ +#include "mbed.h" +#include "TextLCD.h" +#include "FastAnalogIn.h" + + +TextLCD lcd(PTE20,PTE21,PTE22,PTE23,PTE29,PTE30); +Serial pc(USBTX,USBRX); +FastAnalogIn Mic(PTB0); + + +int main () +{ + /* + lcd.cls(); + wait(0.01); + for(int i = 8; i >= 0; i--) + { + lcd.cls(); + lcd.printf("%d",i); + wait(1); + } + lcd.cls(); + lcd.printf("Perro"); + */ + + lcd.cls(); // Clear the screen + float freq = 140; + float oct[7] = {16.35,18.35,20.60,21.82,24.5,27.5,30.86}; + float n; + float nueva_oct[7]; + float nueva_octf; + + for (int i = 0; i <= 6; i = i+1){ + if (freq >= 14.35 && freq <= 34.22) + { + n = 0; + } + if (freq > 34.22 && freq <= 63.56) + { + n = 1; + } + if (freq > 63.56 && freq <= 127.14) + { + n = 2; + } + if (freq > 127.14 && freq <= 254.28) + { + n = 3; + } + if (freq > 254.28 && freq <= 508.26) + { + n = 4; + } + if (freq > 508.26 && freq <= 1017.13) + { + n = 5; + } + if (freq > 1017.13 && freq <= 2034.26) + { + n = 6; + } + if (freq > 2034.26 && freq <= 4068.54) + { + n = 7; + } + + float power1 = pow((float)2,(float)n); + nueva_oct[i] = oct[i]*power1; + } + + nueva_octf = nueva_oct[6] + 1.84*pow(2,n); + + if (freq >= (nueva_oct[0] - (nueva_oct[1] - nueva_oct[0])/2) && freq < (nueva_oct[0] + (nueva_oct[1] - nueva_oct[0])/2)) + { + if (freq < (nueva_oct[0] - (nueva_oct[1] - nueva_oct[0])/8)) + { + lcd.printf("C %1.0f Aprieta",n); + } + if (freq > (nueva_oct[0] + (nueva_oct[1] - nueva_oct[0])/4)) + { + lcd.printf("C %1.0f Afloja",n); + } + if (freq <= (nueva_oct[0] + (nueva_oct[1] - nueva_oct[0])/4) && freq >= (nueva_oct[0] - (nueva_oct[1] - nueva_oct[0])/8)) + { + lcd.printf("C %1.0f",n); + } + } + + if (freq >= (nueva_oct[1] - (nueva_oct[1] - nueva_oct[0])/2) && freq < (nueva_oct[1] + (nueva_oct[2] - nueva_oct[1])/2)) + { + if (freq < (nueva_oct[1] - (nueva_oct[1] - nueva_oct[0])/4)) + { + lcd.printf("D %1.0f Aprieta",n); + } + if (freq > (nueva_oct[1] + (nueva_oct[2] - nueva_oct[1])/4)) + { + lcd.printf("D %1.0f Afloja",n); + } + if (freq <= (nueva_oct[1] + (nueva_oct[2] - nueva_oct[1])/4) && freq >= (nueva_oct[1] - (nueva_oct[1] - nueva_oct[0])/4)) + { + lcd.printf("D %1.0f",n); + } + } + + + + //lcd.printf("%2.0f%",oct[0]); + wait(0.01); + lcd.locate(0,1); + lcd.printf("%f",nueva_octf); + + while (true) + { + float MicF = Mic; + pc.printf("%2.2f\n",MicF); + wait (0.1); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-dsp.lib Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/mbed-official/code/mbed-dsp/#7a284390b0ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 21 00:12:06 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file