Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:84f45646bc00
diff -r 000000000000 -r 84f45646bc00 main.cpp
--- /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
+ }
+}
+