aine

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
stanislashzc
Date:
Sat Feb 08 22:18:56 2014 +0000
Commit message:
cosine

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 6048eae7eed6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 08 22:18:56 2014 +0000
@@ -0,0 +1,47 @@
+
+#include "mbed.h"
+AnalogOut DA(PTE30);
+AnalogIn AD(PTB0);
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+    float da;
+    float Amp = 2.0;
+    float w = 1.0;
+    float pi = 3.14159;
+    
+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):\n");
+    pc.scanf("%f", &Amp);
+    pc.printf("%f\n", Amp);
+    //Amp = (float)AA;
+    pc.printf("Input parameter w:\n");
+    pc.scanf("%f", &w);
+    pc.printf("%f\n", w);
+    //w = (float)ww;
+ }
+
+
+int main(void) {
+        
+    
+    pc.attach(&callback);
+    
+    while(1){
+        for (float i=0; i<360; i++) {
+            da = Amp*(sin(w*i/180*pi)*0.5+0.5);
+            DA.write(da);
+            
+            pc.printf("%f ",da);
+            
+            
+            //AD.read()*3.3;
+        }
+        //wait(3.0);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 6048eae7eed6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 08 22:18:56 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file