FRDM-K64 USB Mouse basic example using mbed

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-K64 USB Mouse basic example using mbed

FRDM-K64 USB Mouse basic example using mbed

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:

  • USBMouse.h
  • FXOS8700Q.h

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);

    }

}

Attachments
No ratings
Version history
Last update:
‎06-27-2014 11:44 AM
Updated by: