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:
- 2:a6db66722be0
- Parent:
- 1:6dd9eca697db
- Child:
- 3:768cca7d53fe
diff -r 6dd9eca697db -r a6db66722be0 main.cpp
--- 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
