Using an accelerometer to move a ball on an LED screen.

Dependencies:   UniGraphic mbed

Revision:
1:c436c1b8333b
Parent:
0:708949ec9140
Child:
2:c6bf8599c398
--- a/main.cpp	Thu Jan 14 23:22:30 2016 +0000
+++ b/main.cpp	Wed Jan 20 21:20:23 2016 +0000
@@ -19,22 +19,26 @@
     myLCD.background(Black);    // set background to red
     myLCD.foreground(White);    // set chars to black
     myLCD.cls();                // clear the screen
+    /*
     myLCD.locate((myLCD.width()-7)/2,myLCD.height()/2);        // from our view, first is yPos, second is xPos
     myLCD.printf("Target Practice\r\n");
     wait(2);
     myLCD.cls();
+    */
+    wait(1);
     while(1) {
         //temporary code:
         myLCD.circle(120,160,12,White);
-        myLCD.fillcircle(X,Y,6,Green);        
+        myLCD.fillcircle(X,Y,6,Blue);        
         getAccel(data);
-        pc.printf("x = %+1.2fg\t y = %+1.2fg\n\r", data[0], data[1]); //print
-        if (X < myLCD.width() && X > 0)
-            X += data[0]/0.004;
-        if (Y < myLCD.height() && Y > 0)
-            Y += data[1]/0.004;
+        pc.printf("x = %1.2fg\t y = %1.2fg\t z = %1.2fg \n\r", data[0], data[1], data[2]); //print
+        if (((X + data[0]) < myLCD.width()-10) && (X + data[0]) > 10)
+            X += data[0]*30;
+        if ((Y + data[1]) < myLCD.height()-10 && (Y + data[1]) > 10)
+            Y -= data[1]*30;
         wait(0.02);
         myLCD.cls();
+        
         //insert correct code here:
         
     }