tim007 tim007
/
LV9_Grupa4_Tim007_Zadatak1
Muhamed Mujić Elmir Hodžić
Revision 0:bd4099b0403b, committed 2014-05-12
- Comitter:
- tim007
- Date:
- Mon May 12 16:32:15 2014 +0000
- Commit message:
- LV9_Gropa4_Tim007_Zadatak1
Changed in this revision
diff -r 000000000000 -r bd4099b0403b MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Mon May 12 16:32:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r 000000000000 -r bd4099b0403b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 12 16:32:15 2014 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "MMA8451Q.h" +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +Serial pc(USBTX, USBRX); +MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); +PwmOut crvena(PTB18), zelena(PTB19), plava(PTD1); +Ticker prikaz; + +void PrikaziNaTerminalX() +{ + pc.printf("Po X osi: %f \n", acc.getAccX()); +} + +void PrikaziNaTerminalY() +{ + pc.printf("Po Y osi: %f \n", acc.getAccY()); +} + +void PrikaziNaTerminalZ() +{ + pc.printf("Po Z osi: %f \n", acc.getAccZ()); +} + +void PrikaziNaTerminalKoordinate() +{ + pc.printf("{x,y,z} = {%f,%f,%f} \n",acc.getAccX(),acc.getAccY(), acc.getAccZ()); +} + +int main() +{ + crvena = 1.; + zelena = 1.; + plava = 1.; + + while(true) + { + char komanda = pc.getc(); + + if(komanda == 'X')prikaz.attach(PrikaziNaTerminalX, .5); + else if(komanda == 'Y') prikaz.attach(PrikaziNaTerminalY, .5); + else if(komanda == 'Z') prikaz.attach(PrikaziNaTerminalZ, .5); + else if(komanda == 'A') prikaz.attach(PrikaziNaTerminalKoordinate, .5); + else if(komanda == 'S') prikaz.detach(); + crvena = 1.0 - abs(acc.getAccX()); + zelena = 1.0 - abs(acc.getAccY()); + plava = 1.0 - abs(acc.getAccZ()); + wait(0.1); + } + + return 0; +} \ No newline at end of file
diff -r 000000000000 -r bd4099b0403b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 12 16:32:15 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file