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.
Revision 0:8eb74e68ae2a, committed 2017-11-27
- Comitter:
- andeevan
- Date:
- Mon Nov 27 01:26:55 2017 +0000
- Commit message:
- Initial build from template
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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Nov 27 01:26:55 2017 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+
+AnalogIn analog_value(A0);
+
+DigitalOut led(LED1);
+
+int main()
+{
+ float meas_r;
+ float meas_v;
+
+ 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)
+ meas_v = meas_r * 3300; // Converts value in the 0V-3.3V range
+
+ // Display values
+ printf("measure = %f = %.0f mV\n", 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
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Nov 27 01:26:55 2017 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file