Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q TSI mbed
Fork of snakecontroller by
Diff: main.cpp
- Revision:
- 5:97c02241511c
- Parent:
- 4:1961b60aa8fb
- Child:
- 6:44bac63d4d66
--- 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)
