#include <Wire.h>
#include <LiquidCrystal.h>
#include <MPU6050_tockn.h>
#include <Servo.h>
LiquidCrystal lcd(12, 11, 4, 5, 6, 7);
MPU6050 mpu6050(Wire);
Servo servo1;
Servo servo2;
int potPin1 = A0;
int potPin2 = A1;
int servo1Pin = 9;
int servo2Pin = 10;
void setup() {
lcd.begin(16, 2);
lcd.print("Gyro Reading:");
Wire.begin();
mpu6050.begin();
mpu6050.calcGyroOffsets();
servo1.attach(servo1Pin);
servo2.attach(servo2Pin);
}
void loop() {
mpu6050.update();
float gyroX = mpu6050.getGyroX();
float gyroY = mpu6050.getGyroY();
float gyroZ = mpu6050.getGyroZ();
lcd.setCursor(0, 1);
lcd.print("X:");
lcd.print(gyroX);
lcd.print(" Y:");
lcd.print(gyroY);
lcd.print(" Z:");
lcd.print(gyroZ);
//first servo
int potValue = analogRead(potPin1);
int servo1Angle = map(potValue, 0, 1023, 0,90);
servo1.write(servo1Angle);
//second servo
int potValue2 = analogRead(potPin2);
int servo2Angle2 = map(potValue2, 0, 1023, 180, 90);
servo2.write(servo2Angle2);
}