Here you will find both the code and project files for the USB Mouse project. In this project the USB module is configured as a device, the X and Y coordinates to move the cursor are obtained from the accelerometer measurements. Once the code is loaded it is necessary to disconnect the USB cable from the J26 USB connector and plug it to the K64 USB connector. Once the device enumerates you can use it as an air mouse.
The left and right click buttons have not been enabled.
To compile the project you must import the following libraries:
Code:
#include "mbed.h"
#include "USBMouse.h"
#include "FXOS8700Q.h"
//I2C lines for FXOS8700Q accelerometer/magnetometer
FXOS8700Q_acc acc( PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1);
USBMouse mouse;
int main()
{
acc.enable();
float faX, faY, faZ;
int16_t x = 0;
int16_t y = 0;
while (1)
{
//acc.getAxis(acc_data);
acc.getX(&faX);
acc.getY(&faY);
x = 10*faX;
y = 10*faY;
mouse.move(x, y);
wait(0.001);
}
}