Shows the Battery Voltage

Dependencies:   mbed

Revision:
0:8944b0dbd06a
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);
+    
+
+
+    }
+}