Testing with Daniel

Dependencies:   mbed Blinker TextLCD

Files at this revision

API Documentation at this revision

Comitter:
jurgis
Date:
Sat Feb 11 17:22:03 2017 +0000
Parent:
5:7f4d61016e8c
Commit message:
Testing lcd

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Feb 11 17:22:03 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- 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;
     }
 }