top of page

From Raw Motion to Arduino IDE 3D Stabilization: Visualizing Roll, Pitch, and Yaw with an MKR/MKT1010 and MPU6050

In this project, we are building a real-time orientation visualization system using an Arduino-style microcontroller, an MPU6050 motion sensor, and Processing. The goal is to take raw motion data from the MPU6050, calculate roll, pitch, and yaw, send those values through the serial port, and display the movement as a 3D object on the computer screen.


3D representation using the MPU 6050 in the Processing Coding Program

We have been referring to the board as the MTK1010. In most Arduino IDE 3D Stabilization documentation, the board is likely the Arduino MKR WiFi 1010, which is programmed through the Arduino IDE and communicates with the computer over USB serial.

Useful official links:



Materials Needed



Cost Breakdown for Arduino IDE 3D Stabilization

Arduino MKT Wifi 1010

$39.80 / Unit

MPU 6050 Accelerometer. gyroscope module

1 Unit for $6.98

3 Units for $11.69

USB Cable for Arduino

$6.55 for 2 Units that are 3ft in length

Jumper Wires

$6.88 / Unit

Breadboard

$6.80 / Unit

Total

  • For 1 MPU 6050 Unit: $67.01

  • For 3 MPU 6050 Units: $71.72

  • Prices may vary based on location

Wiring

Connect the MPU6050 to the MKR/MKT1010 using I2C:


  • MPU6050 VCC -> 3.3V

  • MPU6050 GND -> GND

  • MPU6050 SDA -> SDA

  • MPU6050 SCL -> SCL


Note: Most MPU6050 boards use I2C address 0x68. Some clone boards use 0x69 or 0x70, so the Arduino code includes a line you can change if needed.



Software Flow

The data moves through the system like this:


MPU6050 sensor

Raw accelerometer and gyroscope data

Arduino / MKR1010 calculates roll, pitch, and yaw

Arduino sends: roll, pitch, yaw

USB serial port, for example, COM6

Processing reads the serial data

Processing smooths the values

3D object rotates on the screen


The serial information that correlates to this information:

roll,pitch,yaw


will display this information:

12.30,-4.50,90.10



Processing needs the clean comma-separated format. It should not receive this:

Roll: 12.3 Pitch: -4.5 Yaw: 90.1



Arduino IDE Code


  • Upload this code to the Arduino/MKR1010. Keep the MPU6050 still for the first few seconds so the gyro can calibrate.


Processing 3D Visualization Code


Before running Processing, close the Arduino Serial Monitor or Serial Plotter. Only one program can use the COM port at a time.


This sketch uses COM6, since that was the working port in our setup. If your port is different, change this line:


myPort = new Serial(this, "COM6", 9600);


to either COM7 , COM8 , COM9 etc.


Full Sketch:



What the Code Is Doing


The MPU6050 gives us two types of motion data:


  • Accelerometer data: detects tilt and gravity direction

  • Gyroscope data: detects rotation speed


The Arduino combines those readings using a complementary filter. That helps reduce twitching while still allowing the model to react quickly.


Roll, pitch, and yaw mean:


Roll = rotation side to side

Pitch = nose up or nose down

Yaw = turning left or right


One important limitation is that the MPU6050 lacks a magnetometer, so yaw will drift over time. Roll and pitch are more stable because they can be corrected using gravity from the accelerometer.


Testing Steps

  1. Upload the Arduino code.

  2. Open Arduino Serial Monitor.

  3. Confirm the data looks like this:


1.25,-3.62,0.48

1.30,-3.58,0.52


  1. Close Arduino Serial Monitor.

  2. Open Processing.

  3. Run the 3D visualization sketch.

  4. Move the MPU6050 and watch the plane rotate.


If the movement is backward, flip the signs in Processing:


rotateZ(radians(-displayRoll));

rotateX(radians(-displayPitch));

rotateY(radians(displayYaw));


This project creates the foundation for an orientation and stabilization display system: sensor motion becomes serial data, serial data becomes roll/pitch/yaw, and roll/pitch/yaw becomes a live 3D visualization.

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

©2025 by Sigma Unlimited . Proudly created with Wix.com

bottom of page