Mouse pointer based on IMU data

Hello everyone,

I am trying to achieve a mouse pointer like movement with the IMU. In other words, if one moves the sensor to the right, the point would move to the right, if move to the left, then to left, etc.

I am able to get and parse the data from the device, but from that point, I am not sure how to proceed. I tried using the MadgwickAHRS algorithm, but after that only the orientation of the object works. https://github.com/xioTechnologies/Open … ickAHRS.cs

How can I make the object move based on the quaternion or is there another way?

Include an HID library and point the output to a variable that calls the HID functions (move cursor right, etc)

There are also ready-made solutions for this like this https://www.amazon.com/W10-GYRO-Keyboar … B078NT49MJ (the one I use)

Hey TS-Russell , thank you for your quick response. I am still quite new to all of this. Maybe I should have elaborated more on what I am trying to achieve.

I would like to make the movement in another application, where I can have more control of it and it’s behavior. I am using Unity3D. So ideally, the IMU should send the data to a unity application, where I can parse it and do the movement. And also this should be completely wireless.

Would that be still possible with HID library? I found something called Mouse https://www.arduino.cc/reference/en/lan … usb/mouse/. Not sure if it is the one you are referring to.

I tried something else - I took the example in the sketches IMU_DMP_Quat6 and sent the roll, pitch and yaw to may application. I looked at some code from here: https://www.hackster.io/movsensllc/diy- … cro-548353

From there I used this code:

            vertValue = yaw - vertZero;
            horzValue = roll - horzZero;
            vertZero = yaw;
            horzZero = roll;

            if (vertValue != 0)
                transform.position = new Vector3(0, vertValue * sensitivity, 0); // move mouse on y axis
            if (horzValue != 0)
                transform.position = new Vector3(horzValue * sensitivity, 0, 0); // move mouse on x axis

The object moves on the screen, so far so good. However, my object doesn’t move correctly. Does someone here know what could be wrong? I am also not sure what is the correct way to hold the device.