Testing with Daniel

Dependencies:   mbed Blinker TextLCD

Revision:
6:d8bc26e7d471
Parent:
4:62ae68bcaee8
--- a/main.cpp	Sat Jan 07 16:02:04 2017 +0000
+++ b/main.cpp	Sat Feb 11 17:22:03 2017 +0000
@@ -1,9 +1,11 @@
 // Testing MBED with Daniel
 #include "mbed.h"
 #include "Blinker.h"
+#include "TextLCD.h"
 
 Timer timer;
 DigitalOut led1(LED1);
+AnalogIn volatage(A0);
 //DigitalOut greenLed(D8);
 //DigitalOut redLed(D10);
 //DigitalIn button(D9);
@@ -11,6 +13,8 @@
 Serial pc(USBTX, USBRX);
 jj::Blinker blinker1(led1, timer);
 
+TextLCD lcd(D2, D3, D4, D5, D6, D7, TextLCD::LCD20x4); // rs, e, d4-d7
+float prevVoltage = 0;
 
 int main()
 {
@@ -20,8 +24,18 @@
     
     blinker1.blink(200, 1000);
     
+    lcd.cls();
+    
     for(;;)
     {
         blinker1.update();
+        
+        float v = volatage.read() * 3.3f;
+        if (abs(v - prevVoltage) > 0.1f)
+        {
+            lcd.locate(14, 0);
+            lcd.printf("%0.2f V", v);
+        }
+        prevVoltage = v;
     }
 }