HOW TO ROTATE AN STATIC MESH USING ARDUINO MPU6050

Hello, I want to rotate an object in X, Y, and Z, I have tried in several ways, I have been using the plugin found at GitHub - videofeedback/Unreal_Engine_SerialCOM_Plugin: Serial Com Port Library for Unreal Engine 4 and Unreal Engine 5

For Arduino, I am using the following code to get the rotation of a MPU6050 gyroscope, I am using this code:

include “Wire.h”
include “MPU6050.h”

MPU6050 mpu;

void setup() {
Serial.begin(115200);
Wire.begin();
mpu.initialize();
}

void loop() {
int16_t ax, ay, az, gx, gy, gz;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

float rotationX = map(gx, -32768, 32767, 0, 360);
float rotationY = map(gy, -32768, 32767, 0, 360);

Serial.print(rotationX);
Serial.print(“,”);
Serial.print(rotationY);
Serial.print(“,”);
Serial.println(rotationZ);

delay(100);
}

The BluePrintActor of my object looks like this:



image

I do not have your setup, so i cannot guess what is wrong and where.

However after 20+ years of reverse engineering and debugging stuff:

  • find point/place that if all fails. To do this print things out, after loading from arduino, when numbers are sent to function etc. Check all fail points step by step.

  • when you have place that fails, try to fix, repeat first step to find next place that fails.

  • it is usually some silly mistake.

also, draw line traces for rotations (forward vector(multiplied by 900 or so) of rotated component actor).

Just debug/(print and visualize) step by step and find where it gets wrong.

ps.
my blind guess is that you are parsing angles incorrectly from arduino input.