JOe Chacon / Mbed 2 deprecated JChac-342-4_2

Dependencies:   SLCD mbed

Revision:
0:5d6f30101feb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Sep 20 21:50:37 2015 +0000
@@ -0,0 +1,36 @@
+#include "mbed.h"
+#include "SLCD.h"
+
+#define DATATIME 250 // 250 milliseconds
+#define LASTDGDIV 10
+#define PROGNAME "JChac_341_4_2_Analog Rand v1\n\r"
+
+AnalogIn analogRand(PTB0);
+DigitalOut Rled(LED_RED);
+Serial pc(USBTX, USBRX);
+
+SLCD slcd; // New instance of LCD
+
+ 
+void LCDMess(unsigned int lMess){
+        slcd.Home();
+        slcd.clear();
+        slcd.printf("%d", lMess);
+}
+
+int main()
+{
+    float analogValue;
+    unsigned int analogBits;
+    unsigned int lastDigit;
+    pc.printf(PROGNAME);
+    while (true) {
+     analogValue = analogRand.read();
+     analogBits = analogRand.read_u16();
+     lastDigit = analogBits % LASTDGDIV;
+     Rled = !Rled; // toggle red
+     LCDMess(lastDigit);
+     pc.printf("%0.5f, %d, %1d\n\r", analogValue, analogBits, lastDigit); 
+     wait_ms(DATATIME);
+    }
+}
\ No newline at end of file