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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:8b55e947c1eb
diff -r 000000000000 -r 8b55e947c1eb main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Apr 10 16:00:27 2019 +0000
@@ -0,0 +1,13 @@
+#include "mbed.h"
+
+AnalogIn sensor(A1);
+
+int main() {
+ float val;
+ val=sensor.read(); //read the ADC value from pin PA1
+ //VOLTAGE / STEP = REFERENCE VOLTAGE / 4096 = (3.6V/4096= 0.879mV) per unit.
+ float voltage=(val/4096)*3.6; //converts ADC value to voltage
+ while(1) {
+ printf("%.4f\n", voltage); // 0.0 to 1.0
+ wait_ms(100);}
+}