Controller for snake

Dependencies:   MMA8451Q TSI mbed

Fork of foodcontroller3 by Serpentine

Files at this revision

API Documentation at this revision

Comitter:
danlock10y
Date:
Thu Jun 09 10:36:19 2016 +0000
Parent:
4:1961b60aa8fb
Commit message:
Snake Controller

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1961b60aa8fb -r 97c02241511c main.cpp
--- a/main.cpp	Thu Jun 09 10:31:59 2016 +0000
+++ b/main.cpp	Thu Jun 09 10:36:19 2016 +0000
@@ -5,8 +5,6 @@
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
 Serial pc(USBTX, USBRX); // tx, rx
 
-PwmOut gled(LED_GREEN);                             //Indicator for touch sensor Output
-TSISensor tsi;                                      //Setup touch sensor
 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);    //Setup accelerometer
 DigitalOut lefthigh(PTC11);                         //Test LED for left
 DigitalOut leftlow(PTC9);
@@ -21,7 +19,6 @@
 float accY=acc.getAccY();                           //Measure acceleration in Y direction
 
 int Direction;                                      //2 bit number to describe direction 0 forward assigned CW
-int Velocity;                                       //2 bit number to vary velocity in game
 
 bool right;                                         //Right or left? right = 1
 bool forward;                                       //Forward or Backward? forward = 1
@@ -34,29 +31,6 @@
         float accX=acc.getAccX();                           //Measure acceleration in X direction
         float accY=acc.getAccY();                           //Measure acceleration in Y direction
 
-         if (tsi.readDistance() != 0) 
-        {
-//          gled = 1.0 - tsi.readPercentage();          
-            if (tsi.readDistance() <= 13)
-            {
-                Velocity = 3;
-            }
-            if (tsi.readDistance() > 13 && tsi.readDistance() < 26)
-            {
-                Velocity = 2;
-            }
-            if (tsi.readDistance() >= 26)
-            {
-                Velocity = 1;
-            }
-                                   
-            printf("x=%d\r\n",Velocity);
-            wait(0.2);
-
-
-        }//endif touch sensor 
-
-
         if((accX <= 0.1f) && (accX >= -0.1f)) 
         {
             if (right == false)