Receive Analog In signal, and control sampling rate by altering delay time

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
aaronice
Date:
Sun Feb 09 00:03:13 2014 +0000
Commit message:
Receive Analog In signal, and control sampling rate by altering delay time

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
waveRx.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7a7ab8e73be6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 09 00:03:13 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/824293ae5e43
\ No newline at end of file
diff -r 000000000000 -r 7a7ab8e73be6 waveRx.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/waveRx.cpp	Sun Feb 09 00:03:13 2014 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+AnalogIn AD(PTB1);
+Serial pc(USBTX, USBRX); // tx, rx
+
+//Global variable, delay time
+float dt=0;
+
+void callback() {
+    
+    pc.printf("Input parameter dt and press Enter:\n");
+    pc.scanf("%f", &dt);
+    pc.printf("%f\n", dt);
+    pc.printf("Continue...\n");
+    
+    }
+    
+    
+       
+int main(void) {
+        
+    
+    //pc.attach(&callback);
+    
+    while(1){
+        
+            pc.attach(&callback);
+            
+            //Monitor Received Analog In
+            pc.printf("%f ", AD.read());
+            wait(dt);
+           //wait(3.0);
+    }
+}
\ No newline at end of file