from imu import MPU6050
from time import *
from machine import Pin, I2C
from neopixel import Neopixel
sleep(0.1) # Wait for USB to become ready
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
mpu = MPU6050(i2c)
pixels = Neopixel(16, 0, 10, 'GRB')
colors = [(255, 0, 0),
(0, 255, 0),
(0, 0, 255),
(0, 0, 0)]
pixel_index = 0
color_index = 0
while 1:
pixels.set_pixel(pixel_index, colors[0])
pixels.show()
pixel_index += 1
if pixel_index == 16:
pixel_index = 0
color_index += 1
color_index = (color_index + 1) % 2
pixels.fill(colors[3])
sleep(0.1)
ax = round(mpu.accel.x,2)
ay = round(mpu.accel.x,2)
az = round(mpu.accel.x,2)
gx = round(mpu.gyro.x)
gy = round(mpu.gyro.x)
gz = round(mpu.gyro.x)
tem = round(mpu.temperature,2)
# if gx > 60:
# pixels.set_pixel(10, colors[2])
print(f'"ax",ax,"\t","ay",ay,"\t","az",az,"\t","gx",gx,"\t","gy",gy,"\t","gz",gz,"\t","Temperature",tem," ",end="\r"')
sleep(1)