Shows the Battery Voltage

Dependencies:   mbed

main.cpp

Committer:
GRG
Date:
2013-05-10
Revision:
0:8944b0dbd06a

File content as of revision 0:8944b0dbd06a:

#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);
    


    }
}