![](/media/cache/profiles/2ad53786265b672d888710f5183a13c7.jpg.50x50_q85.jpg)
Emulate a mouse using FRDM KL25Z. MMA8451Q accelerometer used for orientation and TSI capacitive touch sensor used for right and Left Click. USBHID class library used for USB protocol implementation.
Dependencies: MMA8451Q TSI USBDevice mbed
Diff: main.cpp
- Revision:
- 0:c4999a91ff36
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 12 04:23:31 2015 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +#include "MMA8451Q.h" + #include "USBMouse.h" + #include "TSISensor.h" +#define MMA8451_I2C_ADDRESS (0x1d<<1) + + Serial pc(USBTX, USBRX); + +int main(void) { + MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); + TSISensor tsi; + while (true) { + float X=acc.getAccX(); + float Y=acc.getAccY(); + mouse.move(Y,X); + if(tsi.readPercentage()>0) + if(tsi.readPercentage()<=0.6) + { + mouse.press(MOUSE_LEFT); + pc.printf("Left\n"); + } + if(tsi.readPercentage()>0.6) + { + mouse.press(MOUSE_LEFT); + pc.printf("Right"); + } + wait(0.5); + } + +} + + + +