First

Dependencies:   UniGraphic mbed

Revision:
6:459d1eb2cc23
Parent:
4:aa5c976a8761
diff -r 98ad3701ec24 -r 459d1eb2cc23 main.cpp
--- a/main.cpp	Thu Jan 14 22:03:54 2016 +0000
+++ b/main.cpp	Thu Jan 14 22:52:20 2016 +0000
@@ -1,24 +1,31 @@
 #include "mbed.h"
 #include "LCD1.h"
+#include "acc.h"
 
-int x,y;
+float x,y;
+float dx,dy;        //degrees x,y
 
-int main() {
+int main() 
+{
+    acc_init();
     LCD_init();
-    acc_init();
-    while(1){
-
-
+    x =160;
+    y =120;
+    dx =0;
+    dy=0;
+    while(1)
+    {
+        dx = acc_sense(1);
+        dy = acc_sense(2);
+        LCD1(x,y);              //send pos to LCD to display
+        x=x+dy/5;                 //apply x of sensor to y of screen (alignment)
+        y=y+dx/5;                 //vice-versa
         
-        ifx><
-        ify<>
-        LED1(x,y);   
-   
-   
-   
-    LCD_init();
-    while(1) 
-    {
-       LCD1(160,120);
+        if(x>314)x=314;         //prevent loss of bubble
+        if(x<6)x=6;
+        if(y>234)y=234;
+        if(y<6)y=6;
+        
+        LCD2(x,y);              //send pos to LCD to display
     }
 }