from machine import Pin, I2C, sleep, PWM
import mpu6050
import time

i2c = I2C(scl = Pin(22), sda = Pin(21))
ledRojo = Pin(13, Pin.OUT)
ledAzul = Pin(14, Pin.OUT)
ledAmarillo = Pin(26, Pin.OUT)
led = PWM(Pin(4),5000)


mpu = mpu6050.accel(i2c)
while True:
  print("led: ",led)
  temps = (mpu.get_values())
  tem = temps["Tmp"] #temperatura del giroscopio
  if tem > 40:
    print("la temperatura es muy alta: ",tem)
    ledRojo.value(1)
    time.sleep(2)
    ledRojo.value(0)
    time.sleep(2)
  gyz = temps["GyZ"]
  gyy = temps["GyY"]
  gyx = temps["GyX"]
  acz = temps["AcZ"]
  acy = temps["AcY"]
  acx = temps["AcX"]

  print(temps)
  print("Giroscopio eje z: ",gyz)
  print("Giroscopio eje y: ",gyy)
  print("Giroscopio eje X: ",gyx)
  print("Aceleracion en el eje Z: ",acz)
  print("Aceleracion eje Y: ",acy)
  print("Aceleracion eje X: ",acx)
  print("-----------------------")
  time.sleep(1)