Arduino Pro Micro and MARG MPU-9250 for Inertial Mouse

posted in: Arduino | 14

In this Arduino Tutorial MPU-9250 Orientation Sensor was used. Actually, only accelerometer data was acquired and used to control mouse cursor in air. Please NOTE that  Arduino Pro (Micro) or Arduino Leonardo should be used for this purpose.

Download # Arduino Code (*.ino file)

Download # MPU-9250 Library (*.zip file)


Upload Arduino code directly to your Microcontroller from website

If you want to integrate Arduino IDE into your website (as above) sign up here: codebender

Follow me:

14 Responses

  1. Aqib Makandar

    Is it possible to control the mouse using (a-star 32u4 micro – a tiny arduino leonardo clone)
    and MPU-9150 ?×500.jpg

    • I don’t know if it is a clone as you say, it might just work out for you. Just try it out and let us know.

  2. It’s very straightforward to find out any topic on net as compared to books, as I found this post at this website.

  3. Can you get this to work with an Arduino Uno or Mega by any chance, an what changes would need to be made to the code.

  4. hi, I’m a noob, I’m having trouble with the sketch wanting mouse.h library. I have a pro micro and mcu9265. I just cant get it to compile! I’ve looked for the mouse.h sketch but haven’t found anything that works. Any ideas would be appreciated.

    • I haven’t used mouse.h. Make sure you follow every step that I show in the video.

      • In your code you have several references to mouse. Has is this implemented?

  5. Hi. Thank you for great sketch.

    Is it possible to remap the x axis (horizontal pointer movement)? I plan to place this mouse on my wrist, and it would be better if the pointer just followed to movements of my hand, eg used z axis (horizontal hand movement) rather than tilting the mouse. Is it possible?
    I tried to change your code but didn’t succeed. Any hint would be appreciated.

  6. And one more question. I noticed that the mouse works really smoothly as soon I upload the code into arduino.
    But if I plug it out of the usb port and then reconnect it – the pointer movement is really laggy. Did I miss something?

  7. Hi, I don’t understand the meaning of variable “Min”, “Max” and function “map” in your Arduino Code, what do they do? Please explain it for me, I really need it for my project, thank you so much.
    float Min = -15;//-30, -45, -15
    float Max = 15;// 30, 45, 15
    int mapX = map(pitchdeg, Min, Max, -6, 6);
    int mapY = map(rolldeg, Min, Max, -6, 6);

  8. There’s no sound in the video.

  9. is it possible to use z axis for horizontal movement and use delta instead absolute value?
    can you explain me how?

    thanks inadvance

  10. Ganesh

    How to make this wireless one (bluetooth)?

Leave a Reply to Aqib Makandar Cancel reply