Shows the Battery Voltage

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
GRG
Date:
Fri May 10 13:57:16 2013 +0000
Commit message:
Battery Life

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 8944b0dbd06a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 10 13:57:16 2013 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+AnalogIn Battery(p15);
+Serial pc(USBTX, USBRX);
+
+int main() {
+    while(1) {
+    
+    float a, Vcc, R1=46.6, R2=11.92 ;
+    
+    a=Battery.read();
+    
+    Vcc = (a*3.3*(R1+R2)/R2) - 0.32;
+    
+    pc.printf(" a = %f \n", a);
+    pc.printf(" Voltage = %f \n", Vcc);
+    wait(1);
+    
+
+
+    }
+}
diff -r 000000000000 -r 8944b0dbd06a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 10 13:57:16 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file