Serpentine
/
foodcontroller
Tilt steering control
Revision 0:8e22f474256a, committed 2016-06-07
- Comitter:
- pemb4660
- Date:
- Tue Jun 07 15:31:48 2016 +0000
- Commit message:
- steering control
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Tue Jun 07 15:31:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jun 07 15:31:48 2016 +0000 @@ -0,0 +1,36 @@ +#include "mbed.h" +#include "MMA8451Q.h" + +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +int main() +{ + MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); + PwmOut rled(LED_RED); + PwmOut gled(LED_GREEN); + bool right; + + while (1) { + + if(acc.getAccX() <= 0.1 && acc.getAccX() >= -0.1) { + if (right == true) { + rled = 0; + } else + gled = 0; + } + + if (acc.getAccX() > 0.1) { + rled = 0; + gled = 1; + right = true; + } + + if (acc.getAccX() < -0.1) { + rled = 1; + gled = 0; + right = false; + } + wait(0.1); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Jun 07 15:31:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file