Shows the Battery Voltage
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 AnalogIn Battery(p15); 00004 Serial pc(USBTX, USBRX); 00005 00006 int main() { 00007 while(1) { 00008 00009 float a, Vcc, R1=46.6, R2=11.92 ; 00010 00011 a=Battery.read(); 00012 00013 Vcc = (a*3.3*(R1+R2)/R2) - 0.32; 00014 00015 pc.printf(" a = %f \n", a); 00016 pc.printf(" Voltage = %f \n", Vcc); 00017 wait(1); 00018 00019 00020 00021 } 00022 }
Generated on Wed Jul 13 2022 13:41:08 by
1.7.2