Used the onboard accelerometer (Freescale MMA8451Q) and capacitive sensor APIs of MBED and developed a mouse that alters its sensitivity with respect to the user input. Extended the gesture USB mouse to give it a wireless capability using an nRF24L01P RX-TX pair.
Dependencies: mbed TSI MMA8451Q USBDevice
Diff: main.cpp
- Revision:
- 0:a582e272f873
diff -r 000000000000 -r a582e272f873 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 23 16:56:28 2019 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" +#include "USBMouse.h" +#include "MMA8451Q.h" +#include "TSISensor.h" + +#define MMA8451_I2C_ADDRESS (0x1d<<1) + +MMA8451Q acc(PTE25,PTE24, MMA8451_I2C_ADDRESS); +TSISensor tsi; +USBMouse mouse; + +int main() +{ + int16_t x = 0; + int16_t y = 0; + int s=10; + + while(1) + { + x= -s*(acc.getAccY()); + y= s*acc.getAccX(); + + mouse.move(x,y); + + //left click + if (tsi.readPercentage() > 0.7) + { + mouse.press(MOUSE_LEFT); + } + else + { + mouse.release(MOUSE_LEFT); + } + //right click + if (tsi.readPercentage() < 0.3 && tsi.readPercentage() > 0) + { + mouse.press(MOUSE_RIGHT); + } + else + { + mouse.release(MOUSE_RIGHT); + } + } +} \ No newline at end of file