Controller for snake
Dependencies: MMA8451Q TSI mbed
Fork of foodcontroller3 by
Diff: main.cpp
- Revision:
- 2:a6db66722be0
- Parent:
- 1:6dd9eca697db
- Child:
- 3:768cca7d53fe
--- a/main.cpp Thu Jun 09 09:27:59 2016 +0000 +++ b/main.cpp Thu Jun 09 09:37:00 2016 +0000 @@ -30,11 +30,28 @@ { while (1) { - if (tsi.readPercentage() != 0) + if (tsi.readDistance() != 0) { - gled = 1.0 - tsi.readPercentage(); +// 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 == true) @@ -115,6 +132,6 @@ backwardlow = 0; forward = false; }//endif - wait(0.1); + wait(0.1);*/ }//endwhile }//endmain