import utime,mpu6050,rgb,gc
mpu6050.init()
while True:
    test = (0,0,0)
    try:
        while test == (0,0,0):
            test = mpu6050.get_accel()
    except:
        pass
    print(test)
    gc.collect()
    rgb.clear()
    x = int((test[0] + 32768) / 2048)
    y = int((test[1] + 32768) / 2048)
    z = int((test[2] + 32768) / 2048)

    #for i in range(0,x):
    rgb.pixel((148,0,211),(x,0))
    #for i in range(0,y):
    rgb.pixel((75,0,130),(y,1))
    #for i in range(0,z):
    rgb.pixel((0,0,255),(z,2))
    test = (0,0,0)
    try:
        while test == (0,0,0):
            test = mpu6050.get_gyro()
    except:
        pass
    x = int((test[0] + 32768) / 2048)
    y = int((test[1] + 32768) / 2048)
    z = int((test[2] + 32768) / 2048)

    #for i in range(0,x):
    rgb.pixel((0,255,0),(x,3))
    #for i in range(0,y):
    rgb.pixel((255,255,0),(y,4))
    #for i in range(0,z):
    rgb.pixel((255,127,0),(z,5))
    try:
        temp = int(mpu6050.get_temp() / 2)
    except:
        pass
    if temp > 31:
        temp = 31
    #for i in range(0,temp):
    rgb.pixel((255,0,0),(temp,6))

    utime.sleep(0.01)