The keyboard section of the CO657 class 4

Dependencies:   C12832 MMA7660 mbed

Revision:
0:85b0a266d4ac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 19 18:05:08 2015 +0000
@@ -0,0 +1,42 @@
+/**
+ * (C) Simon Cooksey, 2015
+ * 
+ *  Class 03, Task 1B -- XBee Remote Sender
+ *  MIT
+ */
+
+#include "mbed.h"
+#include "C12832.h"
+#include "MMA7660.h" /* for the accelerometer */
+
+MMA7660 MMA(D14, D15);              /* accelerometer */
+Serial xbee(D1, D0);                /* xbee */
+C12832 lcd(D11, D13, D12, D7, D10); /* lcd display*/
+
+// Based on Colin Johnson's code available at 
+// https://developer.mbed.org/users/colingj/code/lecture2_demo2/
+int main(void)
+{
+    float x,y;
+    int countdown = 0;
+    
+    lcd.locate(0,0);
+    lcd.printf("Remote");
+    
+    while (1) {
+        x = MMA.x();
+        y = MMA.y();
+        if (y>0.6f) { 
+            xbee.putc('d'); 
+        }
+        if (y<-0.6f) { 
+            xbee.putc('u');
+        }
+        if ((abs(x)>0.6f)&&(countdown<=0.0f)) {
+            xbee.putc('p');
+            countdown = 10;
+        }
+        countdown--;
+        wait (0.1);
+    }
+}
\ No newline at end of file