No Description
Fork of mbed-os-example-mbed5-blinky by
Diff: main.cpp
- Revision:
- 41:bbb75c2a83a9
- Parent:
- 29:0b58d21e87d6
--- a/main.cpp Thu Jul 06 18:30:02 2017 +0100
+++ b/main.cpp Tue Aug 29 00:25:26 2017 +0000
@@ -1,12 +1,22 @@
#include "mbed.h"
-
-DigitalOut led1(LED1);
-
-// main() runs in its own thread in the OS
+
+//DigitalOut myled(LED1);
+AnalogIn battery(A0);
+//DigitalOut battery_warning(p24);
+Serial pc(USBTX, USBRX);
+
int main() {
- while (true) {
- led1 = !led1;
- wait(0.5);
+ 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(5);
}
-}
-
+}
\ No newline at end of file
