Rob Toulson / Mbed 2 deprecated PE_05-05_DataConversion

Dependencies:   mbed

Revision:
0:84f45646bc00
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 15 21:21:42 2012 +0000
@@ -0,0 +1,25 @@
+/*Program Example 5.5: Inputs signal through ADC, and outputs to DAC. 
+View DAC output on oscilloscope. To demonstrate Nyquist, connect variable 
+frequency signal generator to ADC input. Allows measurement of conversion 
+times, and explores Nyquist limit.
+                                                                            */
+#include "mbed.h"
+AnalogOut Aout(p18);      //defines analog output on Pin 18
+AnalogIn Ain(p20);        //defines analog input on Pin 20
+DigitalOut test(p5);
+float ADCdata;
+
+int main() {
+  while(1) {
+    ADCdata=Ain;   //starts A-D conversion, and assigns analog value to ADCdata
+    test=1;        //switch test output, as time marker
+    test=0;
+    Aout=ADCdata;  // transfers stored value to DAC, and forces a D-A conversion 
+    test=1;        //a double pulse, to mark the end of conversion 
+    test=0;     
+    test=1;
+    test=0;             
+    //wait(0.001);    //optional wait state, to explore different cycle times
+   }
+}
+