Dawit Abraham
/
battery_monitor_demo
qwerty
Fork of battery_monitor_demo by
main.cpp
- Committer:
- dabraham
- Date:
- 2017-08-29
- Revision:
- 1:09b1d08854b6
- Parent:
- 0:c674d8c52a7e
File content as of revision 1:09b1d08854b6:
#include "mbed.h" //DigitalOut myled(LED1); AnalogIn battery(p19); //DigitalOut battery_warning(p24); Serial pc(USBTX, USBRX); int main() { pc.baud(9600); const float BAT_MUL = 10.26; float sample; while(1) { sample = battery.read(); pc.printf("VBat: %4.3f, ADC: %4.3f, Vadc: %4.3f\r\n", sample*BAT_MUL, sample, sample*3.3); if(sample*BAT_MUL < 6.4) battery_warning = 0; else battery_warning = 1; wait(1); } }