![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Isme have me mouse chalate h, jyada excite mat hona keep calm and roll on
Dependencies: MMA8451Q TSI USBDevice mbed
Fork of LAB21_AccLed by
Revision 1:ab380860081d, committed 2016-07-08
- Comitter:
- akashlal
- Date:
- Fri Jul 08 07:26:58 2016 +0000
- Parent:
- 0:5fc7faf6f68c
- Commit message:
- na
Changed in this revision
diff -r 5fc7faf6f68c -r ab380860081d TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Fri Jul 08 07:26:58 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
diff -r 5fc7faf6f68c -r ab380860081d USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Fri Jul 08 07:26:58 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#01321bd6ff89
diff -r 5fc7faf6f68c -r ab380860081d main.cpp --- a/main.cpp Sat Jul 02 07:19:44 2016 +0000 +++ b/main.cpp Fri Jul 08 07:26:58 2016 +0000 @@ -1,37 +1,37 @@ #include "mbed.h" #include "MMA8451Q.h" +#include "TSISensor.h" +#include "USBMouse.h" #define MMA8451_I2C_ADDRESS (0x1d<<1) -Serial pc(USBTX, USBRX); MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); -DigitalOut r(PTB18); -DigitalOut g(PTB19); -DigitalOut b(PTD1); - -int main() { - int xvali, yvali, zvali; - while(1) { - xvali = (acc.getAccX()+2)*100; - yvali = (acc.getAccY()+2)*100; - zvali = (acc.getAccZ()+2)*100; - pc.printf("$%d %d %d;",xvali,yvali,zvali); - if(xvali>230||xvali<170) +TSISensor tsi; +USBMouse mouse; +int main() +{ + int16_t x, y; + int s=10; + float click=0; + while(1) + { + x = acc.getAccY()*-s; + y = acc.getAccX()*s; + mouse.move(x,-y); + click=tsi.readPercentage(); + if(click>0&&click<=0.4) { - r=0; - g=1; - b=1; + mouse.press(MOUSE_RIGHT); } - if(yvali>230||yvali<170) + else { - r=1; - g=0; - b=1; + mouse.release(MOUSE_RIGHT); } - if(zvali>230||zvali<170) + if(click>=0.6) { - r=1; - g=1; - b=0; + mouse.press(MOUSE_LEFT); } - // wait(0.2); + else + { + mouse.release(MOUSE_LEFT); + } } }