Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 11 months ago. This question has been closed. Reason: Duplicate question
Air Mouse code not running
I want 3 library files can anyone help me out USBMouse.h" MMA8451Q.h" "TSISensor.h"
when i compile code USBMouse.h library file showing error i think this library are for older verison where can i get this library files or issue in code
This my code:
- include "mbed.h"
- include "USBMouse.h"
- include "MMA8451Q.h"
- include "TSISensor.h"
- define MMA8451_I2C_ADDRESS (0x1d<<1)
USBMouse mouse; MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); TSISensor tsi;
typedef enum {NONE = 0, LEFT, RIGHT} Click;
int main() { int16_t x = 0, y = 0; float t; Click in_click = NONE;
while (1) { t = acc.getAccX(); t *= 10/1.5; y = (int16_t) t;
t = acc.getAccY(); t *= 10/1.5; x = - (int16_t) t;
t = tsi.readPercentage();
if (in_click == NONE) { if (t > 0.6) { mouse.press(MOUSE_LEFT); in_click = LEFT; } else if (t > 0.1) { mouse.press(MOUSE_RIGHT); in_click = RIGHT; } } else if (in_click == LEFT) { if (t <= 0.6) { mouse.release(MOUSE_LEFT); in_click = NONE; } } else { if (t > 0.6 || t <= 0.1) { mouse.release(MOUSE_RIGHT); in_click = NONE; } }
mouse.move(x, y); wait(0.001); } }