No Description

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Files at this revision

API Documentation at this revision

Comitter:
dabraham
Date:
Tue Aug 29 00:25:26 2017 +0000
Parent:
40:d4500ea4f3aa
Commit message:
Blinky

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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