from machine import Pin, I2C
from mpu6050 import MPU6050
# Initialize I2C communication
i2c = I2C(scl=Pin(22), sda=Pin(21), freq=100000)
# Initialize MPU6050
mpu = MPU6050(i2c)
while True:
# Read accelerometer data
accel = mpu.get_accel_data()
x_accel, y_accel, z_accel = accel["x"], accel["y"], accel["z"]
# Print orientation
print(f"X: {x_accel:.2f} m/s^2, Y: {y_accel:.2f} m/s^2, Z: {z_accel:.2f} m/s^2")
# Add a delay (adjust as needed)
utime.sleep_ms(100)