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:5797ba5402c6
- Child:
- 1:c00ab08066b6
diff -r 000000000000 -r 5797ba5402c6 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 05 07:37:23 2017 +0000
@@ -0,0 +1,18 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+AnalogIn a0(A0);
+
+const float vcc = 3.3; // Vcc voltage
+const float r1 = 10; // R1 [k-ohm]
+const float r2 = 30; // R2 []
+
+int main() {
+ while(1) {
+ myled = !myled; // LED is toggled
+
+ float vo = a0.read()*vcc; // Vo (analog voltage)
+ float vp = r2/(r1+f2) * vo;
+ printf("Analog %7.1f [v]\n", vp);
+ }
+}