Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
msouchet
Date:
Mon Sep 24 07:56:51 2018 +0000
Commit message:
Base de TP de BTS MS 2?me ann?e : conversion analogique num?rique

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 12f8d507f070 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 24 07:56:51 2018 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+
+AnalogIn analog_value(A0);
+
+DigitalOut led(LED1);
+
+int main()
+{
+    float meas_r;
+    float meas_v;
+    unsigned int variable;
+    
+    printf("\nAnalogIn example\n");
+
+    while(1) {
+
+        meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+         variable = analog_value.read_u16();
+        meas_v = meas_r * 3300; // Converts value in the 0 mV - 3300 mV range
+
+        
+        // Display values
+        printf("measure = %d = %f = %.0f mV\n", variable, meas_r, meas_v);
+
+        // LED is ON is the value is below 1V
+        if (meas_v < 1000) {
+            led = 1; // LED ON
+        } else {
+            led = 0; // LED OFF
+        }
+
+        wait(1.0); // 1 second
+    }
+}
diff -r 000000000000 -r 12f8d507f070 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Sep 24 07:56:51 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/994bdf8177cb
\ No newline at end of file