from machine import Pin, ADC, I2C
from utime import sleep, sleep_ms
from ssd1306 import SSD1306_I2C
from MPU6050 import MPU6050
ancho = 128
alto = 64
i2c = I2C(0, scl = Pin(22), sda = Pin(21))
oled = SSD1306_I2C(ancho, alto, i2c)
mpu= MPU6050(i2c)
print("Dirección Mac:", hex(i2c.scan()[0]), hex(i2c.scan()[1]))
while True:
TEM = mpu.read_temperature()
GYRO = mpu.read_gyro_data()
ACEL = mpu.read_accel_data()
print(TEM, GYRO, ACEL)
oled.fill(0)
oled.pixel(64, 32, 1)
oled.hline(0, 0, 128, 1)
oled.hline(0, 20, 128, 1)
oled.vline(0, 0, 20, 1)
oled.vline(127, 0, 20, 1)
oled.text("MPU6050", 30, 8, 1)
oled.text("T = {:.1f}".format(TEM), 30, 28, 1)
oled.text("GX:{:.0f},GY:{:.0f},GZ:{:.0f}".format(GYRO[0], GYRO[1], GYRO[2]), 0, 38, 1)
oled.show()