#include <Wire.h>
#include <MPU6050_tockn.h>
#include <ESP32Servo.h>
MPU6050 mpu6050(Wire);
Servo myServo;
const int servoPin = 1;
void setup() {
Serial.begin(115200);
Wire.begin();
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
myServo.attach(servoPin);
Serial.println("Sistema inicializado.");
}
void loop() {
mpu6050.update();
float angleX = mpu6050.getAngleX();
int servoAngle = map(angleX, -90, 90, 0, 180);
servoAngle = constrain(servoAngle, 0, 180);
myServo.write(servoAngle);
delay(1); /
}