ESE519
/
Lab3_Acc
part3
Revision 0:cad38d31219a, committed 2015-03-03
- Comitter:
- jaredwil
- Date:
- Tue Mar 03 19:24:53 2015 +0000
- Commit message:
- part3;
Changed in this revision
diff -r 000000000000 -r cad38d31219a MMA7660.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA7660.lib Tue Mar 03 19:24:53 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/Sissors/code/MMA7660/#36a163511e34
diff -r 000000000000 -r cad38d31219a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 03 19:24:53 2015 +0000 @@ -0,0 +1,69 @@ +//Uses the measured z-acceleration to drive leds 2 and 3 of the mbed + +#include "mbed.h" +#include "MMA7660.h" + +MMA7660 MMA(p28, p27); +BusOut leds(LED1,LED2,LED3,LED4); + +//used for debugging +Serial pc(USBTX, USBRX); + +int main() { + if (MMA.testConnection()) + leds = 0x1; + wait(1); + leds = 0x0; + float x = 0, y = 0, z = 0; + while(1) { + leds = 0x0; + x = MMA.x(); + y = MMA.y(); + z = MMA.z(); + +//NOTE: All directions based on looking at device with MBED cord towards +//the user + if(x > 0.5){ //Forward + leds = 0x6; + wait(1); + } + if(x < -0.5){ //Backwards + leds = 0x9; + wait(1); + } + if(y > 0.5){ //LEFT + leds = 0xE; + wait(1); + } + if(y < -0.5){ //RIGHT + leds = 0x7; + wait(1); + } + if((z) > 1.2){ //UP + leds = 0xF; + wait(1); + } + if((z) < 0.5){ //DOWN + leds = 0xA; + wait(0.2); + leds = 0x5; + wait(0.2); + leds = 0xA; + wait(0.2); + leds = 0x5; + wait(0.2); + leds = 0xA; + wait(0.2); + leds = 0x5; + wait(0.2); + } + + + + + //for debug + //pc.printf("x: %f y: %f z: %f \r",MMA.x(),MMA.y(),MMA.z()); + + } + +}
diff -r 000000000000 -r cad38d31219a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Mar 03 19:24:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file