q

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dosukoidaisaku
Date:
Sat Aug 06 07:15:22 2016 +0000
Commit message:
q

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 c36b20cba727 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Aug 06 07:15:22 2016 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+
+AnalogIn in(A0);
+
+#if !DEVICE_ANALOGOUT
+#error You cannot use this example as the AnalogOut is not supported on this device.
+#else
+AnalogOut out(PA_4);
+#endif
+
+DigitalOut led(LED1);
+
+int main()
+{
+    printf("\nAnalog loop example\n");
+    printf("*** Connect A0 and PA_4 pins together ***\n");
+    while(1) {
+        for (float out_value = 0.0f; out_value < 1.1f; out_value += 0.1f) {
+            // Output value using DAC
+            out.write(out_value);
+            wait(0.1);
+            // Read ADC input
+            float in_value = in.read();
+            // Display difference between two values
+            float diff = fabs(out_value - in_value);
+            printf("(out:%.4f) - (in:%.4f) = (%.4f) ", out_value, in_value, diff);
+            if (diff > 0.05f) {
+                printf("FAIL\n");
+            } else {
+                printf("OK\n");
+                printf("\033[1A"); // Moves cursor up of 1 line
+            }
+            led = !led;
+        }
+    }
+}
+
diff -r 000000000000 -r c36b20cba727 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Aug 06 07:15:22 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f9eeca106725
\ No newline at end of file