Aaron Huang
/
WaveGen
Generate sine wave, using analog output
Diff: main.cpp
- Revision:
- 4:ec289b4b7758
- Parent:
- 3:be30774cb93f
diff -r be30774cb93f -r ec289b4b7758 main.cpp --- a/main.cpp Fri Feb 14 08:00:07 2014 +0000 +++ b/main.cpp Sat Feb 15 08:53:25 2014 +0000 @@ -1,6 +1,6 @@ - #include "mbed.h" AnalogOut DA(PTE30); + //AnalogIn AD(PTB1); Serial pc(USBTX, USBRX); // tx, rx @@ -10,21 +10,19 @@ float w = 1.0; float pi = 3.14159; float deltaT = 0.01; + void callback() { // Note: you need to actually read from the serial to clear the RX interrupt - //int AA; - //int ww; printf("%c\n", pc.getc()); wait(0.5); - pc.printf("Input parameter A(<1.0) and press Enter:\n"); + pc.printf("Input parameter A(<=1.0) and press Enter:\n"); pc.scanf("%f", &Amp); pc.printf("%f\n", Amp); - //Amp = (float)AA; pc.printf("Input parameter w and press Enter:\n"); pc.scanf("%f", &w); pc.printf("%f\n", w); pc.printf("Continuing...\n"); - //w = (float)ww; + } @@ -37,13 +35,12 @@ for (float i=0; i<(360); i++) { da = Amp*(sin(w*i/(180)*pi)*0.5+0.5); DA.write(da); - wait(deltaT) + wait(deltaT); pc.printf("%f ",da); //Monitor Received Analog In //pc.printf("%f ", AD.read()); } - //wait(3.0); } } \ No newline at end of file